SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Spread workload
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Luuk123
Starting Member

48 Posts

Posted - 02/12/2014 :  02:11:24  Show Profile  Reply with Quote
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

India
52309 Posts

Posted - 02/12/2014 :  05:27:36  Show Profile  Reply with Quote
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
Starting Member

48 Posts

Posted - 02/12/2014 :  07:22:44  Show Profile  Reply with Quote
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

India
52309 Posts

Posted - 02/12/2014 :  08:33:07  Show Profile  Reply with Quote
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
Starting Member

48 Posts

Posted - 02/12/2014 :  13:20:17  Show Profile  Reply with Quote
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
Constraint Violating Yak Guru

USA
340 Posts

Posted - 02/12/2014 :  14:42:05  Show Profile  Reply with Quote
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

India
52309 Posts

Posted - 02/13/2014 :  08:18:28  Show Profile  Reply with Quote
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

Edited by - visakh16 on 02/13/2014 08:18:46
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000