Re: sorting problem

Поиск
Список
Период
Сортировка
От Lincoln Yeoh
Тема Re: sorting problem
Дата
Msg-id 5.2.1.1.1.20041218040359.02c973c8@localhost
обсуждение исходный текст
Ответ на Re: sorting problem  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
--=======6C297FEF=======
Content-Type: text/plain; x-avg-checked=avg-ok-43C64EFF; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 8bit

At 12:14 PM 12/17/2004 -0500, Tom Lane wrote:

>Bruno Wolff III <bruno@wolff.to> writes:
> > Greg Stark <gsstark@mit.edu> wrote:
> >> where postgres won't bother with the index since it will be slower
> than just
> >> resorting the entire table.
>
> > Using an index to do an order by is an order N operation. Doing a sort
> > is an order N log N operation. For large values of N, a index will be
> > faster.
>
>Unfortunately not ... the constant factors are such that the index
>solution isn't very competitive at large N, unless the table is already
>well ordered (ie clustered).  The sort code is a lot better at avoiding
>random-seeks-all-over-the-disk syndrome.

Which would involve reading less data?

In some cases I'd like to use the method that is more likely to fit within RAM.

Also if there are multiple parallel queries, one could end up with
something similar to random-seeks, so reading/writing less data could still
be better.

Regards,
Link.

--=======6C297FEF=======--


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

Предыдущее
От: Christopher Browne
Дата:
Сообщение: Re: Scheduler in Postgres
Следующее
От: Greg Stark
Дата:
Сообщение: Re: sorting problem