Home » RDBMS Server » Performance Tuning » order by (Oracle9i)
order by [message #483169] Thu, 18 November 2010 21:21 Go to next message
ajaykumarkona
Messages: 399
Registered: August 2010
Senior Member
Hi Experts,

I ran the following query it is taking long time.
Please help me to how to improve the performance of the query.

SELECT  empno,city,state,COUNTRY from app_employee order by empno desc;


The table is having 300000 records.
But it is mandatory to display the records in descending order.

Please help me thanks in advance.

Re: order by [message #483170 is a reply to message #483169] Thu, 18 November 2010 21:25 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>I ran the following query it is taking long time.
quantify "long time".

post EXPLAIN PLAN
is sort done in memory or on disk?
without any where clause a Full Table Scan must be done
Re: order by [message #483184 is a reply to message #483169] Thu, 18 November 2010 23:55 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
The query will need a full table scan and sort as blackswan said.


Instead of going for 300000 records you probably can think of pagination to view records in a particular range.


Regards,
Ved

[Updated on: Thu, 18 November 2010 23:59]

Report message to a moderator

Re: order by [message #483297 is a reply to message #483184] Fri, 19 November 2010 15:23 Go to previous message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Oracle can quickly ORDER BY using an index. In this case - a single table SELECT with no WHERE clause, all you should require is an index on EMPNO and perhaps an INDESX_DESC hint.

Ross Leishman
Previous Topic: Tune the query
Next Topic: Performance tuning (cache sub query results)
Goto Forum:
  


Current Time: Sat Apr 27 11:41:52 CDT 2024