Re: How ad an increasing index to a query result?

Поиск
Список
Период
Сортировка
От Raymond O'Donnell
Тема Re: How ad an increasing index to a query result?
Дата
Msg-id 4ADB3BB7.40508@iol.ie
обсуждение исходный текст
Ответ на Re: How ad an increasing index to a query result?  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Ответы Re: How ad an increasing index to a query result?  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
On 18/10/2009 11:30, Alban Hertroys wrote:

> Short of enumerating those results in your application, the easiest
> approach is probably to wrap your query in a join with generate_series
> like so:
>
> SELECT a, s.b
> FROM (
>     SELECT a
>     FROM table1
>     ORDER BY a DESC LIMIT 5
> ) AS t1, generate_series(5, 1, -1) AS s(b)
>

Won't that just give you the cartesian product of the two sets? I tried
something similar yesterday out of curiosity, and that's what I got.

The only things I can think of are (i) as you say, enumerate the results
in the application or (ii) use a temporary sequence as someone else
suggested.

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Determining dead/unused space in a table?
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: Delete fails with out of memory