Return-Path: postarch
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA25554; Sun, 16 Feb 92 21:22:52 -0800
Message-Id: <9202170522.AA25554@postgres.Berkeley.EDU>
From: postarch (Postgres Mailing Archive)
Subject: Re: Sorting
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
Reply-To: mer@postgres.berkeley.edu
In-Reply-To: Your message of "Thu, 13 Feb 92 09:12:52 PST."
             <9202131712.AA14913@postgres.Berkeley.EDU> 
Date: Sun, 16 Feb 92 21:22:43 PST

you write:
> We use the following commands to sort a class.  Is this way
> appropriate and/or is there a more efficient way?
> 
> The class of interest is called 'scan', a backup of this is called
> 'bscan', and a temporary version of this is 'tscan':
> 
> 	retrieve into tscan (scan.all) sort by key1, key2
> 	destroy bscan
> 	rename scan to bscan
> 	rename tscan to scan

I think this is about the best you can do.  If you have an index
on key1 I believe POSTGRES will take advantage of the ordering when
doing the sort.

> I ask this question because sometimes it seems that this procedure
> gets interrupted and leaves garbage around (this sorting procedure is
> executed at 3:00am every day-- after a vacuum at midnight).

If a query that creates new files (e.g. retrieve into and rename)
in the data directory fails after the file has been created you have to
go in by hand to remove it.  If the above retrieve into fails for some
reason there could be a file $POSTGRESHOME/data/base/dbname/tscan which
POSTGRES won't be willing to remove or overwrite.

We would be interested to know how this is failing...


Jeff Meredith
mer@postgres.berkeley.edu
