is this possible? it should be!

From: newsreader(at)mediaone(dot)net
To: pgsql-general(at)postgresql(dot)org
Subject: is this possible? it should be!
Date: 2001-08-19 17:49:00
Message-ID: 20010819134900.A8735@dragon.universe
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

I have statements (highly simplified just to get
the point across) like

select a,b,c from a where d=2 order by e limit 10;

Now I think that because of "order by" the above query
already "knows" the result of the below query

select count(*) from a where d=2;

The point is that I want to know the total number
of matches and I also want to use "limit". And
I don't want to do two queries.

If it's impossible I would like to know whether
it costs the same to PG if I use it with or
without limit.

If I use DBI and simplified queries look like

$s=$dbh->prepare('select a,b,c from a where d=2 order by e ');
$s->execute();

I get the total number of rows by

$n=$s->rows;

I then use perl to implement "limit"

Thanks in advance for any hints

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Wheeler 2001-08-19 18:48:57 OT: Design Books
Previous Message John Bend 2001-08-19 16:05:05 Re: Cant compile using stock RH71 and libpq++