Re: LIMIT clause and long timings

Поиск
Список
Период
Сортировка
От Christoph Della Valle
Тема Re: LIMIT clause and long timings
Дата
Msg-id 442A205C.40907@goetheanum.ch
обсуждение исходный текст
Ответ на Re: LIMIT clause and long timings  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
would it be faster to use
SELECT * FROM banche ORDER BY banca DESC LIMIT 10 OFFSET 0;

the sorting is done anyway, so at least we don't have to scan through
the table to get the last 10 records?
or is sorting ASC less timeconsuming than sorting DESC?

regards, christoph

Tom Lane schrieb:
> Andrea <andrea.b73@email.it> writes:
>
>>Then I have tried:
>>SELECT * FROM banche ORDER BY banca LIMIT 10 OFFSET 34000;
>>[....]
>>(10 rows)
>
>
>>Time: 2433,000 ms
>
>
>>Why do I get this big timing???
>
>
> Because the system has to scan through 34000 rows before it gets to the
> ten you asked for.  OFFSET is not some bit of black magic, it just
> causes the executor to discard the first N rows it's computed rather
> than sending them over to the client.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
>

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

Предыдущее
От: John DeSoi
Дата:
Сообщение: Re: PHP libpq Version != Actual PGSQL Version
Следующее
От: "Daniel T. Staal"
Дата:
Сообщение: Re: Non-Unique intems