Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Retrieval of rows - Is it FIFO?
Answers embedded...
"Ganesh Vaideeswaran" <divyagan_at_pacbell.net> wrote in message
news:39624098.5F51EA8F_at_pacbell.net...
>
> Hi all,
>
> I am wondering if Oracle returns rows back during retrieval of rows on a
>
> FIFO basis.
> What I mean by this is -
>
> Does Oracle return the first row I inserted as the first row I
> retrieve(assuming that
> there are no WHERE clauses)?
Not necessarily
> ================================
>
> We have a workflow system where we want to retrieve rows based on a
> TimeStamp.
> At present, we do this is using a SELECT statment such as -
>
> SELECT * FROM wfTable WHERE TS=(Select MIN(TS) FROM WF);
>
> TS ==> Name of TimeStamp column.
>
> The other alternative is to use a SELECT statement such as -
>
> SELECT * FROM wfTable ORDER by TS;
>
> Now, which is better? Should I have an index on the TS column?
Yes
> Without the ORDER BY, will I get the rows on a FIFO basis.
No, the 'fifo' order applies to initial load only, after that Oracle will fill 'holes' in your data blocks.
> ================================================
>
> If I am guaranteed to get the rows on a FIFO basis, will the retrieval
> order
> change if I have a WHERE clause such as -
>
> SELECT * FROM wfTable WHERE col1='yyyy';
>
The retrieval order will obviously change if your column col1 is indexed. It will not change if the column is not indexed.
Generally speaking you should *not* rely on *any* order of your data, as that is also against relational principles.
Please use the explain plan facility to get the the execution plans for your
statements. You don't provide any detail about the contents of your table,
and you can't expect us to setup a case for you and reproduce your
statements.
Using the Cost Based Optimizer your execution path is dependent on the
content of your data for 80 to 90 percent.
Sybrand Bakker, Oracle DBA Received on Tue Jul 04 2000 - 00:00:00 CDT
![]() |
![]() |