Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Spread workload

Author  Topic 

Luuk123
Yak Posting Veteran

52 Posts

Posted - 2014-02-12 : 02:11:24
Hi all,

I want to execute a very heavy query on a productiondatabase. I expect the query to run for about 12 hours. Users login to the database 24/7. What can I do to execute my query on for example 25% of the processor so there's minimal impact on the performance for the users?

Thank you.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-12 : 05:27:36
can you take a snapshot and run query if you dont want real time precision?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Luuk123
Yak Posting Veteran

52 Posts

Posted - 2014-02-12 : 07:22:44
I don't think that's an option because the data-page gets copied to the snapshot-database when data on that data-page is queried. (correct me if i'm wrong) I've got a query which has to run just one time and affects almost all tables in my database.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-12 : 08:33:07
quote:
Originally posted by Luuk123

I don't think that's an option because the data-page gets copied to the snapshot-database when data on that data-page is queried. (correct me if i'm wrong) I've got a query which has to run just one time and affects almost all tables in my database.


snapshot will give you readonly copy. didnt understand whats the issue with that.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Luuk123
Yak Posting Veteran

52 Posts

Posted - 2014-02-12 : 13:20:17
I want to delete a lot of records in a lot of tables of the productiondatabase. Taking the database offline is no option and I want the minimal impact on the performance for the users as possible. Because I want te delete a lot of recors I don't think a databssesnapshot is an option, or am I wrong?

Thanks!
Go to Top of Page

ScottPletcher
Aged Yak Warrior

550 Posts

Posted - 2014-02-12 : 14:42:05
Typically to reduce impact you delete in batches, usually between 1000 and, say, 25000 rows, depending on the specifics of your situation.

If necessary, you can add a WAITFOR DELAY in between the deletes to allow other activity full use of the underlying table(s).
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2014-02-13 : 08:18:28
quote:
Originally posted by Luuk123

I want to delete a lot of records in a lot of tables of the productiondatabase. Taking the database offline is no option and I want the minimal impact on the performance for the users as possible. Because I want te delete a lot of recors I don't think a databssesnapshot is an option, or am I wrong?

Thanks!


so then its not read only copy you want.
Why is delete taking 12 hours? is it from single objects or group of objects? why not do truncate if its whole table data that you're purging?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -