Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> How to optimize large ORDER BY queries
Can anyone offer a technique for the following scenario:
I need to set up a "ticket" table that will serve as a queue. The query that gets tickets off the table needs to ORDER the records so that the tickets are processed FIFO. It is a composite ORDER BY clause, using CREATED_DAY, PRIORITY, and TICKET_ID.
At times, records will backlog (to the tune of hundreds of thousands). When this happens, the dequeueing query takes too long, plus processor usage maxes out at 100%.
My question is: can I somehow set it up so that the table's records are physically sorted, so I can simply use ROWNUM = 1 to pull the record I want? Or is there any technique I can use that specifically optimizes ordering? I need to use the index that affects the filter; i.e. the WHERE clause (on different fields). So an index on the ORDER BY fields is not helpful.
Any help is appreciated.
![]() |
![]() |