Re: [HACKERS] Solution for LIMIT cost estimation

Поиск
Список
Период
Сортировка
От Hannu Krosing
Тема Re: [HACKERS] Solution for LIMIT cost estimation
Дата
Msg-id 38A6DADB.D355E3C9@tm.ee
обсуждение исходный текст
Ответ на Solution for LIMIT cost estimation  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [HACKERS] Solution for LIMIT cost estimation  (Don Baccus <dhogaza@pacifier.com>)
Список pgsql-hackers
Chris wrote:
> 
> Tom Lane wrote:
> >
> >         SELECT * FROM table WHERE x > 100 ORDER BY x LIMIT 1;
> 
> Could it _ever_ be faster to sort the tuples when there is already an
> index that can provide them in sorted order?

This has been discussed on this list several times, and it appears that
select+sort is quite often faster than index scan, mainly due to the fact 
that tables live on disk and disk accesses are expensive, and when doing 
index scans:

1- you have to scan two files (index and data), when they are on the same   disk it is much more 2 times slower than
sacnninga single file even  when doing it sequentially
 

2- scans on the both files are random access, so seek and latency times   come into play and readahead is useless

3- you often read the same data page many times

-------------
Hannu


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

Предыдущее
От: Don Baccus
Дата:
Сообщение: Re: [HACKERS] Solution for LIMIT cost estimation
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [HACKERS] Solution for LIMIT cost estimation