Performance Tuning in Count(DISTINCT [message #407416] |
Wed, 10 June 2009 02:38 |
sivakumar.rj
Messages: 17 Registered: November 2008 Location: Chennai
|
Junior Member |
|
|
I have a query which contains COUNT(DISTINCT colname) clause. It takes very long time. Can it be replaced by some other statements or anything else.
SELECT COUNT(DISTINCT a.col1)
FROM tbl1 a,tbl2 b,tbl3 c
WHERE a.col2 = b.col1
AND b.col2 = c.col2
AND fn_mth(a.col3,a.col4,5) = 12
AND a.col5 = :input_value
AND c.col5 = 0;
|
|
|
|
|
|
|
|
Re: Performance Tuning in Count(DISTINCT [message #407473 is a reply to message #407446] |
Wed, 10 June 2009 05:26 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
Prove it to yourself. Run the query WITHOUT that function and compare the run time. If it is much faster, then the function is the problem and there is no point tuning anything BUT the function.
However if you remove the function and it is not much faster (or worse, it is slower) then we can concentrate on tuning the rest of the query.
But the other guys are right, it is almost certainly the function - you just need to convince yourself.
Ross Leishman
|
|
|
|