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
 SQL Server Administration (2008)
 new tables/jobs to minimize cxpacket waits?

Author  Topic 

influent
Constraint Violating Yak Guru

367 Posts

Posted - 2012-05-24 : 16:09:48
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

38200 Posts

Posted - 2012-05-24 : 16:36:10
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

367 Posts

Posted - 2012-05-24 : 17:52:05
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

38200 Posts

Posted - 2012-05-24 : 18:29:47
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

367 Posts

Posted - 2012-05-24 : 20:38:24
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

38200 Posts

Posted - 2012-05-25 : 12:27:21
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
   

- Advertisement -