tricky query

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема tricky query
Дата
Msg-id 6EE64EF3AB31D5448D0007DD34EEB3415C2BEC@Herge.rcsinc.local
обсуждение исходный текст
Ответы Re: tricky query  (Bruno Wolff III <bruno@wolff.to>)
Re: tricky query  (John A Meinel <john@arbash-meinel.com>)
Re: tricky query  (Sam Mason <sam@samason.me.uk>)
Re: tricky query  (Cosimo Streppone <cosimo@streppone.it>)
Список pgsql-performance
I need a fast way (sql only preferred) to solve the following problem:

I need the smallest integer that is greater than zero that is not in the
column of a table.  In other words, if an 'id' column has values
1,2,3,4,6 and 7, I need a query that returns the value of 5.

I've already worked out a query using generate_series (not scalable) and
pl/pgsql.  An SQL only solution would be preferred, am I missing
something obvious?

Merlin

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

Предыдущее
От: Christopher Kings-Lynne
Дата:
Сообщение: Re: Too slow querying a table of 15 million records
Следующее
От: Erik Westland
Дата:
Сообщение: ...