Re: Controlling Reuslts with Limit

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Najm Hashmi <najm(at)mondo-live(dot)com>
Cc: pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Controlling Reuslts with Limit
Date: 2001-02-23 21:46:50
Message-ID: Pine.BSF.4.21.0102231338500.18764-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


It returns the first five rows it finds. Running the same
query over again if there are no updates is safe, but if the
table is updated there is the possibility it would find a different
five rows. If the query would do a seq scan and you updated
a row, the rows would be in a different order in the heap file and so
you'd get a different ordering of rows...

On Sat, 24 Feb 2001, Najm Hashmi wrote:

> Hi,
> I was reading through Bruce's on line . I found follwing bit unclear...
>
> "Notice that each query uses ORDER BY . Although this clause is not required,
> LIMIT without ORDER BY returns random rows from the query, which would be
> useless. "
>
> When I run a query several time I get the same results as given
> flipr=# select song_id from songs limit 5;
> song_id
> ---------
> 945
> 946
> 947
> 948
> 949
> (5 rows)
> ...

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2001-02-23 21:59:09 Re: Controlling Reuslts with Limit
Previous Message Tom Lane 2001-02-23 21:39:27 Re: Controlling Reuslts with Limit