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
 SQL Server Administration (2008)
 new tables/jobs to minimize cxpacket waits?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

influent
Constraint Violating Yak Guru

USA
361 Posts

Posted - 05/24/2012 :  16:09:48  Show Profile  Reply with Quote
My company has several situations where employees need to see very-near-real-time data that typically would be considered OLAP data, such as the number of orders a customer has placed this year. In most of these situations we use stored procedures executed against the OLTP database that take 2-15 seconds (which is reasonable but annoying) but use a lot of CPU and result in CXPACKET waits. In some situations I've created tables that hold e.g. "#orders this year" and I've created a job that updates it every 5 minutes or whatever. Is this typically what people do in these situations or is there a better solution? We're using replication to another server to do reporting but replication is so finicky I hate to point production apps to the reporting server.

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 05/24/2012 :  16:36:10  Show Profile  Visit tkizer's Homepage  Reply with Quote
Why do you say replication is so finicky? We are using it for reporting for our most critical application, and it's near real-time data.

If you are seeing CXPACKET waits, you could try changing the MAXDOP for the query. You should also look into missing indexes.

Could you show us the query, execution plan, and statistics IO and time?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

influent
Constraint Violating Yak Guru

USA
361 Posts

Posted - 05/24/2012 :  17:52:05  Show Profile  Reply with Quote
Replication's been running without issue for several months now but we used to have problems that forced us to reinitialize replication, which takes half an hour. Now the only time we have to reinitialize is after monthly code/schema updates, which is fine. But I just remembered that some of the data comes from a separate database which is not replicated.
If I change MAXDOP to 1 then the waits go away but the query takes 3-4 times longer. I'll check for missing indexes but I've checked several times so I doubt I missed any.
The primary query I'm concerned with is a pretty complex query but the main cause of the slowness is that it's non-sargable. It needs to return data for all customers whose company name or last name or customer number contains the specified search text.
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 05/24/2012 :  18:29:47  Show Profile  Visit tkizer's Homepage  Reply with Quote
You shouldn't even need to reinitialize for most schema changes as replication takes care of most of them. Depends what you are doing, but we only have to reinit maybe once a year and we do upgrades monthly. Our reinit takes an eternity due to the size of the tables, think we're up to 6 hours now.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

influent
Constraint Violating Yak Guru

USA
361 Posts

Posted - 05/24/2012 :  20:38:24  Show Profile  Reply with Quote
Are you using transactional replication? I'd LOVE to know how you're modifying the schema of the publisher without having to reinit. Thanks as always Tara.
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 05/25/2012 :  12:27:21  Show Profile  Visit tkizer's Homepage  Reply with Quote
Yes we are using transactional replication.

It all depends on what types of schema changes you are making. If you are just adding columns, you do not need to reinit. Adding columns is primarily what we do each month. When we add a table, only that table gets initialized, not the whole thing.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
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.06 seconds. Powered By: Snitz Forums 2000