Slow Query [message #545434] |
Wed, 29 February 2012 07:52 |
|
RAM_PIPL
Messages: 5 Registered: December 2011 Location: PUNE
|
Junior Member |
|
|
I have a Table(X_TABLE) That have 6 lac Record .
When I Run this Query It Take 5 min to get Data .
What Should Be the Solution For this...Please Help
SELECT COMP_CD,
DIV_CD,
LOC_CD,
NVL(SUM(GROSS_QTY),0) PEND_GROSS_QTY
FROM X_TABLE
GROUP BY COMP_CD, DIV_CD,LOC_CD
But If I Use This Query It Take Only 20 msecs
SELECT COMP_CD,
DIV_CD,
LOC_CD,
FROM X_TABLE
Regards ,
Ram
|
|
|
|
Re: Slow Query [message #545436 is a reply to message #545434] |
Wed, 29 February 2012 07:57 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
Quote:But If I Use This Query It Take Only 20 msecs
Umm, not really.
You are seeing the first records returned by the query in the second one.
What does an explain plan tell you about your queries?
|
|
|
Re: Slow Query [message #545536 is a reply to message #545436] |
Thu, 01 March 2012 02:09 |
Roachcoach
Messages: 1576 Registered: May 2010 Location: UK
|
Senior Member |
|
|
I should imagine the plans are identical save one has an extra line in the form of sort/group by of some manner, assuming the code is as posted.
As joy_division says, you're being conned by the GUI you're using in the second query.
|
|
|