Re: [HACKERS] Need some help on code

Bruce Momjian <maillist@candle.pha.pa.us>

From: Bruce Momjian <maillist@candle.pha.pa.us>
To: M.Boekhold@et.tudelft.nl
Cc: M.Boekhold@ITS.TUDelft.NL, pgsql-hackers@postgreSQL.org
Date: 1998-06-08T15:16:20Z
Lists: pgsql-hackers
> My thinking was that the reading from the table is very scattered, but 
> that the writing to the new table could be done 'sequentially'. Therefore 
> I thought it was interesting to see if it would help to cluster the writes.
>  
> > Often the fastest way is to discard the index, and just read the table, 
> > sorting each in pieces, and merging them in.  That is what psort does,
> > which is our sort code.  That is why I recommend the SELECT INTO
> > solution if you have enough disk space.
> 
> A 'select into ... order by ...' you mean?  

Yes.  See CLUSTER manual page:

       Another way is to use SELECT  ...  INTO  TABLE  temp  FROM
       ...ORDER  BY ...  This uses the PostgreSQL sorting code in
       ORDER BY to match  the  index,  and  is  much  faster  for
       unordered  data.   You  then drop the old table, use ALTER
 
-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)