MySQL Forums
Forum List  »  Optimizer & Parser

COUNT(1) very slow why?
Posted by: fabio rossi
Date: May 18, 2010 02:56AM

Hi, i've write an application where build query dinamically and one of those return a query count very heavy..

SELECT
COUNT( 1 ) AS COUNT
FROM
((((((((((((((((((((
Tab1
AS Alias0 left JOIN tab2 AS Alias9
ON Alias0.FIELD_BY = Alias9.ID
) LEFT JOIN tab2
AS Alias99 ON Tab0.FIELDX_BY = Alias99.ID
) LEFT JOIN tab2
AS Alias2 on Tab0.FIELDA = Alias2.ID
) LEFT JOIN Tab3
AS Alias3 ON Tab0.FIELD_ID = Alias3.ID
) LEFT JOIN Tab3
AS Alias4 ON Tab0.FIELD_ID = Alias4.ID
) LEFT JOIN Tab3
AS Alias5 ON Tab0.FIELD_ID = Alias5.ID
) LEFT JOIN Tab3
AS Alias6 ON Tab0.FIELD_ID = Alias6.ID
) LEFT JOIN Tab3
AS Alias7 ON Tab0.FIELD_ID = Alias7.ID
) LEFT JOIN Tab3
AS Alias8 ON Tab0.FIELD_ID = Alias8.ID
) LEFT JOIN Tab3
AS Alias99 ON Tab0.FIELD_ID = Alias99.ID
) LEFT JOIN Tab3
AS Alias10 ON Tab0.FIELD_ID = Alias10.ID
) LEFT JOIN Tab3
AS Alias11 ON Tab0.FIELD_ID = Alias11.ID
) LEFT JOIN Tab3
AS Alias12 ON Tab0.FIELD_ID = Alias12.ID
) LEFT JOIN Tab3 AS Alias13
ON Alias0.FIELD_ID = Alias13.ID
) LEFT JOIN Tab4 AS Alias14
ON Alias0.Tab0 = Alias14.ID
) LEFT JOIN tab5 AS Alias15
ON Alias0.FIELD_GRP = Alias15.ID
) LEFT JOIN servicerequests AS T4
ON Alias0.SR_ID = T4.ID
) LEFT JOIN tab6
AS Alias16 ON Alias0.ID = Alias16.ID
) LEFT JOIN tab7
AS Alias17 ON Alias0.FIELD_SK_ID = Alias17.ID
) LEFT JOIN tab7
AS Alias18 ON Alias0.FIELD_PROD = Alias18.ID
)

there's best method to do it?The field are all indexes but exec a FULL SCAN OF Alias0 i don't know how..

Someone can help me?

Options: ReplyQuote


Subject
Views
Written By
Posted
COUNT(1) very slow why?
3335
May 18, 2010 02:56AM
1593
May 20, 2010 09:21PM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.