Re: Returning the total number of rows as a separate column when using limit

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Returning the total number of rows as a separate column when using limit
Date: 2007-11-05 14:18:22
Message-ID: 18728.1194272302@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Andreas Joseph Krogh <andreak(at)officenet(dot)no> writes:
> AFAICS the information about the *total* number of rows is in the "result"
> somehow. When I execute a "limit 1" query with EXPLAIN ANALYZE, I se the
> total number of columns in "rows=200819", so the information is there.

That's only an estimate. Since the query doesn't get executed to
completion thanks to the LIMIT, Postgres really has no idea whether
the estimate is accurate.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Joseph Krogh 2007-11-05 14:38:34 Re: Returning the total number of rows as a separate column when using limit
Previous Message Kenneth Gonsalves 2007-11-05 11:55:58 changing encoding of a postgres database