Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimizing delete SQL
Message
 
To
17/02/2011 12:22:49
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01500559
Message ID:
01500575
Views:
37
>I am looking to see if there could be a way to optimize a delete SQL I have.
>
>Basically, I do something like this every 15 minutes:
>
>
>DELETE FROM Hit WHERE AddDate<something
>
>

Is your 'something' a declared datetime or date datatype, or is it a string being implicitly converted?

>As this is executed every 15 minutes, usually, this is executed in a flash. So, all records from the Hit table which are older than the parameter will be removed. The situation is when I run this command on a test server, where this procedure hasn't been executed since a while, the process may take several minutes.
>
>Is it because I am working on a date field? If yes, I can do a SQL at first to get the primary key and then remove anything older than that primary key.
>
>Or, is it that it is because there are a lot of records? If this is the case, what can I do to optimize?
____________________________________

Don't Tread on Me

Overthrow the federal government NOW!
____________________________________
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform