Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Query Optimization help Expand / Collapse
Author
Message
Posted Wednesday, October 9, 2013 1:11 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 18, 2014 10:45 PM
Points: 119, Visits: 490
I am trying to optimize one query which runs in SSIS package.
I ran db tuning advisor as well, it recommended 2 non clustered indexes and 7 create statistics for that query.

Issue: it runs sometime fine and gives results in 1.25 mins.
sometimes it runs for hours and hours. else I will kill the process and again re-run.
I see when db log backup or differential runs, it goes to suspended status. at that time we kill the process and wait until the job
completes, and rerun.
I also verified that this query was created 3 yrs ago and I am not much that familiar with tuning queries.

I see the CPU utilization increases high and DiskIO also increases high when this SSIS package runs.

Can anyone desperately help me in tuning the query.
Please find the attached.


Cheers,
- Win
"Dont Judge a Book by its Cover"


  Post Attachments 
DB_DOLBY_ALLOC_Query.txt (35 views, 8.64 KB)
Post #1502937
Posted Wednesday, October 9, 2013 1:32 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 5:57 AM
Points: 5,308, Visits: 9,694
If you don't have much experience of tuning queries, then I would advise you to seek advice from someone does. You'll need to pay for that if you don't have anyone in your organisation. If you post the Actual execution plan, we can take a look and point out anything that's obvious, but we can't see your table definitions or data and therefore it's difficult for us to offer anything other than general suggestions.

John
Post #1502944
Posted Wednesday, October 9, 2013 3:50 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 18, 2014 10:45 PM
Points: 119, Visits: 490
Thanks for your reply.

I tuned it to better than earlier, since earlier query was bit critical with joins.
But I am not that much proficient to minimize the query and tune it.
I created the recommended Index, but now its in Index scan.

Please find the attached execution plan and suggest me.


Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1502993
Posted Wednesday, October 9, 2013 4:52 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 3:12 AM
Points: 870, Visits: 2,780
As John mentioned, we need the Actual execution plan and not the estimated plan. I also suggest not using NOLOCK everywhere.



The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Post #1503013
Posted Wednesday, October 9, 2013 6:41 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 18, 2014 10:45 PM
Points: 119, Visits: 490
Thanks for your response.
As per the logic we need to fetch full data from tables.
I modified the script using temp tables in it is working as expected, normal run as of now.


Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1503339
Posted Wednesday, October 9, 2013 10:29 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 18, 2014 10:45 PM
Points: 119, Visits: 490
Please find the actual execution plan.
Please let me know for any recommendations and modifications in the query as posted earlier.

The logic is, we need to pull complete data from a table XXIST, where it fetches 70 billions of records every run (scheduled).

Awaiting for responses.

Have great times..


Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1503367
Posted Friday, October 11, 2013 2:47 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, August 18, 2014 10:45 PM
Points: 119, Visits: 490
Any help is appreciated.

Cheers,
- Win
"Dont Judge a Book by its Cover"
Post #1503918
Posted Friday, October 11, 2013 4:41 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 3:12 AM
Points: 870, Visits: 2,780
There are a number of performance issues here. I would quote a client 2 days minimum to optimize this one. However what did jump out at me was the excessive lookups from [DB_Staging].[dbo].[EXCPTRNSPF] due to a poor estimation. Make sure stats are up to date on [EXCPTRNSPF].



You might see decent improvements if you can make [idx_EXCPTRNSPF_i_nc_02] covering by including LOBCODE.




The SQL Guy @ blogspot

@SeanPearceSQL

About Me


  Post Attachments 
Lookups.png (149 views, 11.47 KB)
Post #1503941
Posted Friday, October 11, 2013 4:47 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 3:12 AM
Points: 870, Visits: 2,780
[JOKE]
What's in tbl_gods_lineOfBusiness. Does the query only run on Sunday's?
[/JOKE]




The SQL Guy @ blogspot

@SeanPearceSQL

About Me
Post #1503942
Posted Friday, October 11, 2013 7:51 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 3:23 PM
Points: 13,272, Visits: 12,103
One other thing is you might want to read up on NOLOCK. You have it littered all over this query. That hint is not a magic go fast solution. It is fraught with a number of very real and possible negative impacts. It can and will return duplicate and/or missing rows which can be nearly impossible to recreate on demand. Please read up and understand what that hint does.

http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/11/10/1280.aspx

http://blogs.msdn.com/b/davidlean/archive/2009/04/06/sql-server-nolock-hint-other-poor-ideas.aspx

http://www.jasonstrate.com/2012/06/the-side-effect-of-nolock/


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1504018
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse