Re: [HACKERS] What about LIMIT in SELECT ?

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: eric(at)linux-hw(dot)com (Eric Lee Green)
Cc: jeff(at)remapcorp(dot)com, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] What about LIMIT in SELECT ?
Date: 1998-10-13 21:16:54
Message-ID: 199810132116.RAA11249@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs pgsql-hackers

> Theoretically a cursor is superior to the "LIMIT" clause because you're
> eventually going to want the B's and K's and etc. anyhow -- but only in a
> stateful enviornment. In the stateless web environment, a cursor is
> useless because the connection can close at any time even when you're
> using "persistent" connections (and of course when the connection closes
> the cursor closes).
>
> I wanted very badly to use PostgreSQL for a web project I'm working on,
> but it just wouldn't do the job :-(.

See my other posting mentioning the FAQ item on this subject. If you
are going after only one table(no joins), and have no ORDER BY, we could
short-circuit the evaluation, but how many queries could use LIMIT in
that case? Zero, I think.

What we could do is _if_ there is only one table(no joins), and an index
exists that matches the ORDER BY, we could use the index to
short-circuit the query.

I have added this item to the TODO list:

* Allow LIMIT ability on single-table queries that have no ORDER BY or
a matching index

This looks do-able, and a real win. Would this make web applications
happier? If there is an ORDER BY and no index, or a join, I can't
figure out how we would short-circuit the query.

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Bruce Momjian 1998-10-13 21:18:34 Re: [HACKERS] What about LIMIT in SELECT ?
Previous Message Marc G. Fournier 1998-10-13 20:48:25 Re: [HACKERS] What about LIMIT in SELECT ?

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-10-13 21:18:34 Re: [HACKERS] What about LIMIT in SELECT ?
Previous Message Bruce Momjian 1998-10-13 21:05:43 Re: [HACKERS] What about LIMIT in SELECT ?