Home » RDBMS Server » Performance Tuning » Slow Query (Oracle 10 g)
Slow Query [message #545434] Wed, 29 February 2012 07:52 Go to next message
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 #545435 is a reply to message #545434] Wed, 29 February 2012 07:57 Go to previous messageGo to next message
cookiemonster
Messages: 10859
Registered: September 2008
Location: Rainy Manchester
Senior Member
Please read and follow How to use [code] tags and make your code easier to read?
Please read How to tune SQL or Identify Performance Problem and Bottleneck and supply the requested information
Re: Slow Query [message #545436 is a reply to message #545434] Wed, 29 February 2012 07:57 Go to previous messageGo to next message
joy_division
Messages: 4490
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 Go to previous message
Roachcoach
Messages: 1181
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.
Previous Topic: Explain plan got changed suddenly
Next Topic: undo tbalespace full, which is rectified but now having big WAIT
Goto Forum:
  


Current Time: Thu Jul 31 21:31:21 CDT 2014

Total time taken to generate the page: 0.13001 seconds