order by [message #483169] |
Thu, 18 November 2010 21:21 |
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 #483184 is a reply to message #483169] |
Thu, 18 November 2010 23:55 |
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 |
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
|
|
|