Re: Efficiency of CREATE TABLE AS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Brian Herlihy <btherl(at)yahoo(dot)com(dot)au>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Efficiency of CREATE TABLE AS
Date: 2007-05-09 05:57:31
Message-ID: 21701.1178690251@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Brian Herlihy <btherl(at)yahoo(dot)com(dot)au> writes:
> If I do the following
> CREATE TABLE foo AS SELECT * FROM bar
> and a sequential scan is chosen as the plan (in particular, no
> ordering required), will the rows be written directly into the new
> table?

Yes ... actually, the plan has nothing to do with it.

> I am concerned about the case where there may be many
> gigabytes of data being copied between these two tables. And my
> precise concern is that the data may be stored temporarily before
> being placed in the new table, slowing things down.

No. The computed tuples go to the new table, noplace else. See
intorel_receive() and related code.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Loredana Curugiu 2007-05-09 12:07:37 Count rows group by time intervals
Previous Message Brian Herlihy 2007-05-09 05:34:10 Efficiency of CREATE TABLE AS