Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> ORDER BY vs MIN to implement FIFO

ORDER BY vs MIN to implement FIFO

From: Saeed <sr_ng_at_goawaynms-sys-lts.demon.co.uk>
Date: Thu, 24 Jun 2004 16:55:46 +0100
Message-ID: <68tk9yACmv2AFw$c@nms-sys-ltd.demon.co.uk>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US