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

TSQL joined Views Expand / Collapse
Author
Message
Posted Thursday, February 21, 2013 1:55 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 6:45 AM
Points: 13, Visits: 237
Hi all
I am having some problems understanding this one.
I have a stored proc (written by the developers), that's using up unnecessary resources.
Basically the stored proc makes use of multiple views. These views contain nested conditional select statements.
Each view contains around 1million odd rows and there are around 8 views.
The problem i am having is that i see pressure on the tempdb log files??? why would this be, i can understand tempdb data files being used for caching but log files??? can someone clear this up for me...thanks all!!!!
...One more thing is there any way to make this faster???
thanks all!!!!
Post #1422438
Posted Thursday, February 21, 2013 2:09 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: 2 days ago @ 3:45 AM
Points: 572, Visits: 1,157
Tempdb may be use while grouping sorting etc.

You should look ate the execution plan and see whether any index/ query rewrite can help.
If you need help please share the execution plan, table structure.


-- Roshan Joe
*******************************************
Jeff Moden -Forum Etiquette: How to post data/code on a forum to get the best help
Custom cleanup script for backups
Post #1422444
Posted Thursday, February 21, 2013 2:16 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 6:45 AM
Points: 13, Visits: 237
Well execution plan seems to be using a "hash match(inner join)", do you know anything about this?
although i don't see any #tables?
Post #1422447
Posted Thursday, February 21, 2013 2:33 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: 2 days ago @ 3:45 AM
Points: 572, Visits: 1,157
Hash match can spill to tempdb.

details on hash join
http://technet.microsoft.com/en-us/library/ms189313(v=sql.105).aspx


-- Roshan Joe
*******************************************
Jeff Moden -Forum Etiquette: How to post data/code on a forum to get the best help
Custom cleanup script for backups
Post #1422455
Posted Thursday, February 21, 2013 2:44 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 6:45 AM
Points: 13, Visits: 237
This is my problem exactly! thanks bud!!!
Post #1422461
Posted Thursday, February 21, 2013 2:50 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: 2 days ago @ 3:45 AM
Points: 572, Visits: 1,157
Glad to help:)

-- Roshan Joe
*******************************************
Jeff Moden -Forum Etiquette: How to post data/code on a forum to get the best help
Custom cleanup script for backups
Post #1422462
Posted Thursday, February 21, 2013 3:56 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, March 26, 2013 8:41 AM
Points: 2,562, Visits: 3,451
Modest DBA (2/21/2013)
One more thing is there any way to make this faster?
Yes and the first step would be tune your stored proc
1 try to restrict the query to required columns
2 apply proper filter which should/must use indexes.
3 if intermediate steps are playing with large volume data , try to store them in temp table have indexes on them and use them in later part.



-------Bhuvnesh----------
While 1 = 1 (Learning SQL....)
Click to get fast response of your post
Post #1422488
Posted Friday, February 22, 2013 1:48 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 2:38 PM
Points: 1,318, Visits: 1,763
Usually views contain lots of columns that aren't really needed when several of them are joined to produce a new result set.

Stop using the views and code directly against the underlying tables when possible, unless the views are just "dummy" views of "SELECT * FROM tablename" to remove dependencies on the actual table name.


SQL DBA,SQL Server MVP('07, '08, '09)
One man with courage makes a majority. Andrew Jackson
Post #1423250
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse