Re: tricky query

Поиск
Список
Период
Сортировка
От John A Meinel
Тема Re: tricky query
Дата
Msg-id 42C1701D.5040102@arbash-meinel.com
обсуждение исходный текст
Ответ на tricky query  ("Merlin Moncure" <merlin.moncure@rcsonline.com>)
Список pgsql-performance
Merlin Moncure wrote:

>>Not so bad. Try something like this:
>>
>>SELECT min(id+1) as id_new FROM table
>>    WHERE (id+1) NOT IN (SELECT id FROM table);
>>
>>Now, this requires probably a sequential scan, but I'm not sure how
>>
>>
>you
>
>
>>can get around that.
>>Maybe if you got trickier and did some ordering and limits. The above
>>seems to give the right answer, though.
>>
>>
>
>it does, but it is still faster than generate_series(), which requires
>both a seqscan and a materialization of the function.
>
>
>
>>I don't know how big you want to scale to.
>>
>>
>
>big. :)
>
>merlin
>
>

See my follow up post, which enables an index scan. On my system with
90k rows, it takes no apparent time.
(0.000ms)
John
=:->


Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Insert performance vs Table size
Следующее
От: Sam Mason
Дата:
Сообщение: Re: tricky query