Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> ORDER BY vs MIN to implement FIFO
A table holds data of jobs. Some are waiting to be actioned. A query is
required to pull out the the one that has been in this stae the longest.
The two options are:
SELECT job_id FROM jobs WHERE status = 'W' ORDER BY job_id
Then OPEN, FETCH, CLOSE just one row.
The other option is
SELECT MIN(job_id) FROM jobs WHERE status = 'W'
Tests indicate the ORDER BY option is slightly more expensive, but the trace shows much higher disk reads than using MIN.
Anyone got any opinions as to which would be the better choice?
Kind regards,
Saeed
sr_ng 786 Received on Thu Jun 24 2004 - 10:55:46 CDT
![]() |
![]() |