Re: Yet Another COUNT(*)...WHERE...question

Поиск
Список
Период
Сортировка
От Phoenix Kiula
Тема Re: Yet Another COUNT(*)...WHERE...question
Дата
Msg-id e373d31e0708150836s1115447aw4944c133f1b247b4@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Yet Another COUNT(*)...WHERE...question  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Ответы Re: Yet Another COUNT(*)...WHERE...question
Список pgsql-general
> Yes, optimization. :)  You don't need an exact count to tell someone
> that there's more data and they can go to it.


In general, I agree. But my example of Amazon was only to illustrate
the point about two queries and why they may be needed. I seem to see
many more pages than you do, but in any case, Google and Amazon can
afford to be less precise.

Thanks for the suggestion of using EXPLAIN and parsing an
approximation, but when you need to show a trader how many trades he
has made, for instance, then approximation is not a possibility at
all. Especially not if the numbers sway so wildly --


FIRSTDB=# explain select * from trades where t_id = 'kXjha';
                                    QUERY PLAN
-----------------------------------------------------------------------------------
 Bitmap Heap Scan on trades (cost=15.77..1447.12 rows=374 width=224)
   Recheck Cond: ((t_id)::text = 'kXjha'::text)
   ->  Bitmap Index Scan on trades_tid_date  (cost=0.00..15.67 rows=374 width=0)
         Index Cond: ((t_id)::text = 'kXjha'::text)
(4 rows)

FIRSTDB=# select count(*) from trades where t_id = 'kXjha';
 count
-------
  3891
(1 row)



Could I do something so that the EXPLAIN showed up with slightly more
close-to-accurate stats? The above query is just after a "vacuum
analyze"!

Much appreciate the suggestions.

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

Предыдущее
От: Richard Broersma Jr
Дата:
Сообщение: Re: Customizing psql console to show execution times
Следующее
От: "Leif B. Kristensen"
Дата:
Сообщение: Re: Customizing psql console to show execution times