Re: Having problems with a 25 million row table on 8.1.3

Поиск
Список
Период
Сортировка
От Andrew - Supernews
Тема Re: Having problems with a 25 million row table on 8.1.3
Дата
Msg-id slrne4t4tu.1pj7.andrew+nonews@atlantis.supernews.net
обсуждение исходный текст
Ответ на Having problems with a 25 million row table on 8.1.3  (Tony Caduto <tony_caduto@amsoftwaredesign.com>)
Список pgsql-general
On 2006-04-25, Tony Caduto <tony_caduto@amsoftwaredesign.com> wrote:
> Hi,
> I have a client who has a 25 million row table that is used to keep
> track of financial security info.
> So far it has worked great, but today someone wanted to get all the tax
> codes(there are lot's of dupes) from the table.
> So we tried this:
>
> select DISTINCT tax_code from warehouse.sec_trans
> We let this run for 1/2 hour or so and canceled it.
>
> Then I tried select DISTINCT ON (tax_code) tax_code from warehouse.sec_trans
>
> same deal, had to cancel it.

select tax_code from warehouse.sec_trans group by tax_code;

Both of the DISTINCT variants rely on sorting. GROUP BY, on the other hand,
can use a hash aggregate, which will be much more efficient where the number
of distinct values is low. Of course it will still need to scan the whole
table...

--
Andrew, Supernews
http://www.supernews.com - individual and corporate NNTP services

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

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Having problems with a 25 million row table on 8.1.3
Следующее
От: "Bert"
Дата:
Сообщение: SQL Rule