Re: AW: Inserting a select statement result into another ta ble - Mailing list pgsql-hackers

From Tom Lane
Subject Re: AW: Inserting a select statement result into another ta ble
Date
Msg-id 1633.971497330@sss.pgh.pa.us
Whole thread Raw
In response to AW: Inserting a select statement result into another ta ble  (Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at>)
List pgsql-hackers
Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at> writes:
>> This is an interesting idea.  We don't allow ORDER BY in 
>> INSERT INTO ...
>> SELECT because it doesn't make any sense, but it does make sense if
>> LIMIT is used:

> An "order by" also makes sense if you want to create a presorted table
> for faster access. I don't see why we should disallow it.

In current sources:

regression=# insert into int4_tbl select * from int4_tbl order by f1;
INSERT 0 5
regression=# select * from int4_tbl;    f1
-------------          0     123456    -123456 2147483647-2147483647-2147483647         <<= insertion starts here
-123456         0     123456 2147483647
 
(10 rows)

LIMIT won't work without some further code-rejiggering, but I think
it should be made to work eventually.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Optimisation deficiency: currval('seq')-->seq scan, constant-->index scan
Next
From: Bruce Momjian
Date:
Subject: Re: Optimisation deficiency: currval('seq')-->seq scan, constant-->index scan