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 -> Re: ORDER BY vs MIN to implement FIFO

Re: ORDER BY vs MIN to implement FIFO

From: Gary Floam <floam_at_comcast.net>
Date: Thu, 24 Jun 2004 21:28:53 -0400
Message-ID: <vvOdnbOeovfo40bdRVn-gw@comcast.com>


Min is much better. Why have the server prepare a cursor-full of records when you only want one of them.

"Saeed" <sr_ng_at_goawaynms-sys-lts.demon.co.uk> wrote in message news:68tk9yACmv2AFw$c_at_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 - 20:28:53 CDT

Original text of this message

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