Subject: Sorting

From: [email-masked]
Date: Thu, 13 Feb 92 09:12:52 -0800

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 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).

Thanks,

Andy. ([email-masked])

---

From: postarch (Postgres Mailing Archive)
Date: Sun, 16 Feb 92 21:22:43 PST

> 	retrieve into tscan (scan.all) sort by key1, key2

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.

> 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
[email-masked]