Re: Much Ado About COUNT(*)

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Much Ado About COUNT(*)
Дата
Msg-id 20050119161638.GA5725@wolff.to
обсуждение исходный текст
Ответ на Re: Much Ado About COUNT(*)  ("Mark Cave-Ayland" <m.cave-ayland@webbased.co.uk>)
Ответы Re: Much Ado About COUNT(*)
Список pgsql-hackers
On Wed, Jan 19, 2005 at 14:59:17 -0000, Mark Cave-Ayland <m.cave-ayland@webbased.co.uk> wrote:
>     BEGIN;
>     INSERT INTO person (first_name, .... Tel) VALUES ('Fred', ....
> '12345');
>     INSERT INTO person_count(id) VALUES (currval('id_seq'));
>     COMMIT;
> 
> 
> So then I would use SELECT COUNT(*) FROM person_count whenever I wanted to
> know the current number of person records. How much quicker would a COUNT(*)
> be if visibility were included in the indices as opposed to a "hacked"
> approach like this?

You are only going to get a constant factor speed up unless the space savings
allows much better use of cache. You probably want to look at using
triggers to maintain counts in another table.


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

Предыдущее
От: Travis P
Дата:
Сообщение: Re: ARC patent
Следующее
От: Yann Michel
Дата:
Сообщение: Caching of frequently used objects