Re: Database tuning

Поиск
Список
Период
Сортировка
От Antonio Fiol Bonnín
Тема Re: Database tuning
Дата
Msg-id 3C23977D.6000109@w3ping.com
обсуждение исходный текст
Ответ на Database tuning  ("K Old" <kevsurf4@hotmail.com>)
Ответы Re: Database tuning  (Nevermind <never@nevermind.kiev.ua>)
Re: Database tuning  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
>
>
>>XXX is a random value ranking from 0 (or 1) to the maximum id value. You
>>generate it outside the database.
>>
>Maximum id is not good solution, beacuse some of ids between 0 (or 1)
>could be missing for some reasons. You should:
>
>select id from table;
>
SEQ SCAN. Avoid for big tables.

>Then chose random one outside SQL, and then:
>
>select * from table where table.id = '$random_id';
>
>This would be slower but will work for sure.
>
Probably even slower than original. Not sure, though.

>Another approach -- select random id outside SQL from 0 (or 1) to
>maximum_id and then trying to select with 'where table.id =
>'$random_id'' until you've got > 0 rows in result.
>
The only drawback that I see to this approach is that it may not find a
result in a finite time.

Better: "Compress" your table so that it holds all continuous IDs. This
may be painful and long, but it will pay off in the end, if your table
is not updated often, so this operation only needs to be done once.

I guess The Bible is not updated very often. ;-)

Antonio




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

Предыдущее
От: Helge Bahmann
Дата:
Сообщение: udp port
Следующее
От: Nevermind
Дата:
Сообщение: Re: Database tuning