From: Miroslav Šulc <miroslav.sulc@startnet.cz>
Cc: pgsql-sql@postgresql.org
Subject: Re: Most efficient way to hard-sort records
Date: Tue, 09 May 2006 10:54:19 +0200
Message-ID: <446058BB.5090201@startnet.cz> (raw)
In-Reply-To: <op.s87d3dxscigqcu@apollo13>
References: <445C5A94.4020907@startnet.cz>
<Pine.GSO.4.64.0605061507500.7602@coe.tamu.edu>
<op.s8590fficigqcu@apollo13>
<Pine.GSO.4.64.0605070837330.12629@coe.tamu.edu>
<op.s87d3dxscigqcu@apollo13>
Hi PFC,
the generate_series() seems to be the right thing I need in my scenario
but I didn't figure out how to create a SELECT stattement that will
contain sorted main_table.id in first column and generated series in
second column which I would use to update the main_table.position. Is it
possible? How can I do that? Or is there another approach to employ
generate_series()?
Miroslav Šulc
PFC napsal(a):
>
>> Another version along that line ?
>>
>> # create sequence counterseq start 1;
>> -- (set/reset whenever a counter is needed)
>>
>> # select main_table.*, nextval('counterseq') as position2
>> into sorted_main_table
>> from main_table, keytable where main_table.id =
>> keytable.main_table_id
>> order by value;
>
> You could also use generate_series(), but I don't know if it can
> generate unbounded series...
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
Attachments:miroslav.sulc.vcf (text/x-vcard, 361B) download
begin:vcard
fn;quoted-printable:Miroslav =C5=A0ulc
n;quoted-printable:=C5=A0ulc;Miroslav
org:StartNet s.r.o.
adr;quoted-printable;quoted-printable:;;Schodov=C3=A1 309/10;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika
email;internet:miroslav.sulc@startnet.cz
tel;cell:+420 603 711 413
x-mozilla-html:TRUE
url:http://www.startnet.cz
version:2.1
end:vcard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: miroslav.sulc@startnet.cz
Subject: Re: Most efficient way to hard-sort records
In-Reply-To: <446058BB.5090201@startnet.cz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox