Re: LIMIT BASED ON PERCENT

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: LIMIT BASED ON PERCENT
Дата
Msg-id 162867790911181139s38dd9ae4n7b1474523d3f2c3b@mail.gmail.com
обсуждение исходный текст
Ответ на Re: LIMIT BASED ON PERCENT  (Lee Hachadoorian <lee.hachadoorian@gmail.com>)
Список pgsql-sql
2009/11/18 Lee Hachadoorian <lee.hachadoorian@gmail.com>:
> On Wed, Nov 18, 2009 at 2:30 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>> yes, and don't use 20%.
>>
>> select * from foo order by somecol limit (select (count(*)*0.2)::int from foo)
>>
>> Regards
>> Pavel
>
> Is this faster on a large table? Because (select (count(*)*20/100)) worked fine.
>

this is +/- same - 20/100 is maybe about 0.000001% faster - you don't
need one float to query cast, but this operation is only one pqr
query. The problem is two  full scan of table.

Pavel


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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: LIMIT BASED ON PERCENT
Следующее
От: Kris Kewley
Дата:
Сообщение: Re: LIMIT BASED ON PERCENT