473,491 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Slow SQL Trigger

1 New Member
Issues with a SQL trigger, it takes 10 seconds to run and I cannot see why...please can you help:

Expand|Select|Wrap|Line Numbers
  1. USE [Sound]
  2. GO
  3. SET ANSI_NULLS ON
  4. GO
  5. SET QUOTED_IDENTIFIER ON
  6. GO
  7. ALTER TRIGGER [dbo].[trSound_Changepath]
  8.    ON  [dbo].[SoundFiles]
  9.    AFTER INSERT
  10. AS
  11. BEGIN
  12.  
  13.     SET NOCOUNT ON;
  14.  
  15.     UPDATE s
  16.     SET s.[SoundFile] = 'D:\Recordings' + substring(i.[SoundFile] , 40 , len(i.[SoundFile] ) - 26)
  17.     FROM dbo.[SoundFiles] s
  18.     JOIN inserted i
  19.     ON s.[SoundFile] = i.[SoundFile]
  20.     WHERE Left(i.[SoundFile],2) = 'C:'
  21.     AND i.[SoundFile] <> 'c:\M2.encrypt'
  22.  
  23.  
  24. END
Jul 3 '12 #1
1 1900
Rabbit
12,516 Recognized Expert Moderator MVP
Please use code tags when posting code.

Avoid functions on fields when possible. Instead of your left, use a like.

Put an index on soundfile.

That'll be about as fast as you can make it.
Jul 3 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
21808
by: Jenny | last post by:
Hi! I wonder how to use conditions in the inserted table(in a insert/update) trigger? The inserted table contain all the rows that have been updated or inserted (for an update/insert trigger),...
9
11204
by: Lauren Quantrell | last post by:
Is there a way to create a text file (such as a Windows Notepad file) by using a trigger on a table? What I want to do is to send a row of information to a table where the table: tblFileData has...
1
6120
by: Gent | last post by:
am using FOR UPDATE triggers to audit a table that has 67 fields. My problem is that this slows down the system significantly. I have narrowed down the problem to the size (Lines of code) that need...
6
6530
by: Scott CM | last post by:
I have a multi-part question regarding trigger performance. First of all, is there performance gain from issuing the following within a trigger: SELECT PrimaryKeyColumn FROM INSERTED opposed...
4
1561
by: nosbtr1 | last post by:
When a row gets modified and it invokes a trigger, we would like to be able to update the row that was modified inside the trigger. This is (basically) how we are doing it now: CREATE TRIGGER...
13
4087
by: Tolik Gusin | last post by:
Hello All, DB2 UDB 8.1 FP3 for Linux The table has 4 triggers on the Insert operation. Three triggers small (200 bytes) and one trigger large (3 ËÂ). In the large trigger there is one long...
2
966
by: Agnes | last post by:
I got two same tables (invoice, invoice_history) When user insert the record, (i will save a copy in the table invoice_history) when user amend the record, (i iwll save the updated record in the...
1
6769
by: Gregi | last post by:
Hello, I'm using VS2005 and SQL 2005. Is it possible for a SQL trigger to immediately raise an event in my C# program? Actually it's C++/CLI, but it's easy to translate C# -C++/CLI, so any...
1
8967
by: db2admin | last post by:
Hello, I lack knowledge about triggers. I have created trigger on table A Table A ------------------------------------------------- ID INTEGER CASEID ...
3
7304
by: lenygold via DBMonster.com | last post by:
Thank you very much SERGE for your help. I found example in Graeme Birchall COOKBOOK wich i think exactly what i need for SQL check in triggers: • User query joins to table function - sends...
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6852
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.