Re: getting count for a specific querry

Поиск
Список
Период
Сортировка
От Rod Taylor
Тема Re: getting count for a specific querry
Дата
Msg-id 1112979092.92363.250.camel@home
обсуждение исходный текст
Ответ на Re: getting count for a specific querry  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
> > select * from mytable where somecondition AND uniquecol>? 
> >                       ORDER by uniquecol limit 50 OFFSET 50;
> 
> > where the ? is placeholder for last value returned by last query.
> 
> Uh, you don't want the OFFSET there do you?  But otherwise, yeah,
> this is a popular solution for paging through some rows.  Doesn't really
> help with the problem of counting the total dataset though ...

In the past I've done an EXPLAIN and parsed the plan to see what
PostgreSQL estimated for the number of <somecondition>. If less than
$threshhold, I would do a count(*). If more than $threshhold I would
display to the user "approx N records".

This seemed to be good enough for most cases.
-- 



В списке pgsql-sql по дате отправления:

Предыдущее
От: Stef
Дата:
Сообщение: Numeric and CSV under 8.0.1 ?
Следующее
От: Ragnar Hafstað
Дата:
Сообщение: Re: getting count for a specific querry