Re: rows and array - Mailing list pgsql-general

From Tom Lane
Subject Re: rows and array
Date
Msg-id 9645.1109086153@sss.pgh.pa.us
Whole thread Raw
In response to Re: rows and array  (Richard Huxton <dev@archonet.com>)
List pgsql-general
Richard Huxton <dev@archonet.com> writes:
> FERREIRA William (COFRAMI) wrote:
>> i can store rows and re-order them like this :
>> children(i-j) := children(i-j-1);

> Well, I'd look at one of three solutions:
>   1. Functional index to order by
>   2. Temporary table (read up on EXECUTE and OID caching)
>   3. pl/perl/python (which are better suited to this sort of thing)

I think what he's saying is he wants to do the re-ordering on the client
side.  This seems trivial enough.  If I were doing it against a libpq
result set, I'd probably not bother to sort the physical rows; I'd just
make an array of integers representing row numbers in the PGresult and
sort the row numbers, then use those numbers to pull out the fields when
it came time to display 'em.  (Another way to say that is that a
PGresult *is* an array, it's just got a funny access syntax.)

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: migration
Next
From: Joe Maldonado
Date:
Subject: vacuuming slow