x

performance without Index

How can I optimize following query and improve performance? Limitation is I can not create indexes.

 SELECT CV.OID_TABA AS OID,
    CV.TopID_TABA AS TopID,
    CV.*,
    RStruct0.f1 AS 'E.FName',
    RStruct0.f2 AS 'E.LName',
    RStruct1.f3 AS 'PA.Type',
    RStruct2.f4 AS 'TA.Title',
    RStruct3.f5 AS 'D.CTitle',
    RStruct3.f6 AS 'D.Title'
 FROM   TABLE_TABA AS CV
    LEFT OUTER JOIN
    TABLE_RA AS ObjRship0
    ON (CV.OID_TABA = ObjRship0.OID1)
    LEFT OUTER JOIN
    TABLE_TABB AS RStruct0
    ON (ObjRship0.OID2 = RStruct0.OID_TABB)
    LEFT OUTER JOIN
    TABLE_RB AS ObjRship1
    ON (CV.OID_TABA = ObjRship1.OID1)
    LEFT OUTER JOIN
    TABLE_AB AS RStruct1
    ON (ObjRship1.OID2 = RStruct1.OID_AB)
    LEFT OUTER JOIN
    TABLE_RC AS ObjRship2
    ON (CV.OID_TABA = ObjRship2.OID1)
    LEFT OUTER JOIN
    TABLE_D AS RStruct2
    ON (ObjRship2.OID2 = RStruct2.OID_D)
    LEFT OUTER JOIN
    TABLE_E AS ObjRship3
    ON CV.OID_TABA = ObjRship3.ParentObjectId
    LEFT OUTER JOIN
    TABLE_F AS RStruct3
    ON ObjRship3.OID = RStruct3.OID_F
more ▼

asked Mar 23, 2012 at 11:56 AM in Default

avatar image

manan.hshah
0 1 1 1

Query takes 8 mins when it should take 20 seconds. This query returns almost 1000000 records. Index on primary key - i.e. on OID is created. Each table contains more that 300000 records.

Mar 23, 2012 at 12:09 PM manan.hshah

did it used to take 20 seconds then started taking 8 mins? If so, can you identify what changed (amount of data/hardware/patches/query text/etc)?

Mar 23, 2012 at 03:57 PM KenJ

I'm with Ken on this - how do you calculate 'should take 20 secs' - is that prior experience or expected results?

Mar 23, 2012 at 04:44 PM Kev Riley ♦♦
(comments are locked)
10|1200 characters needed characters left

3 answers: sort voted first

What is the issue with performance?
Is it taking 10 minutes when it should take 2 seconds, or is it taking 2 secs when it should take 1 ms?
How many rows does this return?
What indexes are already in place?
What sizes are these tables?

Some general pointers :

  • Remove the CV.* - this is returning all columns from the TABLE_TABA table - this might be 3000 ntext columns for all I know

more ▼

answered Mar 23, 2012 at 12:03 PM

avatar image

Kev Riley ♦♦
66.2k 48 65 81

I agree that removing CV.* will help me but I want it :(

Mar 23, 2012 at 12:10 PM manan.hshah

How many columns does represent? What I mean is replace with the column names.

Mar 23, 2012 at 12:11 PM Kev Riley ♦♦

Try running without the CV* and see if there is an improvement or not. It could help zero in on the issue.

And are the PKs clustered indexes?

Mar 23, 2012 at 12:17 PM Blackhawk-17

Does the execution plan show you any pain points?

Mar 23, 2012 at 04:43 PM Kev Riley ♦♦
(comments are locked)
10|1200 characters needed characters left
  1. I think you should look at Execution plan and check out how many rows are returned and size of each row.

more ▼

answered Mar 23, 2012 at 05:28 PM

avatar image

inder
211 18 19 25

(comments are locked)
10|1200 characters needed characters left

This will give you the data being pumped by your query and then find the data transfer rate for you IO system .Then you can count the minimum time taken to transfer the data.Try to find out how far is this value from time taken. IF the value is near to actual time you get then you need faster IO device. Give some detail about the query plan.

more ▼

answered Mar 23, 2012 at 05:31 PM

avatar image

inder
211 18 19 25

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x75
x48

asked: Mar 23, 2012 at 11:56 AM

Seen: 1116 times

Last Updated: Mar 23, 2012 at 05:31 PM

Copyright 2018 Redgate Software. Privacy Policy