X-Original-To: pgsql-docs-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 87AFBD7878 for ; Tue, 11 Oct 2005 20:12:52 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52196-10 for ; Tue, 11 Oct 2005 23:12:48 +0000 (GMT) Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) by svr1.postgresql.org (Postfix) with ESMTP id 94361D7876 for ; Tue, 11 Oct 2005 20:12:50 -0300 (ADT) Received: by flake.decibel.org (Postfix, from userid 1001) id 14F721524F; Tue, 11 Oct 2005 18:12:54 -0500 (CDT) Date: Tue, 11 Oct 2005 18:12:53 -0500 From: "Jim C. Nasby" To: David Fetter Cc: PostgreSQL Docs Subject: Re: COPY example for partial tables Message-ID: <20051011231253.GL23883@pervasive.com> References: <20051011230217.GD6239@fetter.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051011230217.GD6239@fetter.org> X-Operating-System: FreeBSD 4.11-RELEASE-p10 i386 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 required=5 tests=[AWL=0.008] X-Spam-Level: X-Archive-Number: 200510/25 X-Sequence-Number: 3270 Why the vacuum? Seems a bit sever to do a vacuum of an entire database just because you created a temp table. On Tue, Oct 11, 2005 at 04:02:17PM -0700, David Fetter wrote: > Folks, > > Please find enclosed a patch (should work for 7.3 and up) that > illustrates a workaround for using COPY on parts of tables using > temporary tables. It's helped me, and it seems popular via a very > brief and un-scientific poll. > > Cheers, > D > -- > David Fetter david@fetter.org http://fetter.org/ > phone: +1 510 893 6100 mobile: +1 415 235 3778 > > Remember to vote! > Index: doc/src/sgml/ref/copy.sgml > =================================================================== > RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/copy.sgml,v > retrieving revision 1.67 > diff -c -r1.67 copy.sgml > *** doc/src/sgml/ref/copy.sgml 5 Sep 2005 14:44:05 -0000 1.67 > --- doc/src/sgml/ref/copy.sgml 11 Oct 2005 23:00:40 -0000 > *************** > *** 709,714 **** > --- 709,730 ---- > > > > + To copy just the countries whose names start with 'A' into a file > + using a temporary table which goes away at the end of the > + transaction. This workaround will probably not be > + needed for PostgreSQL 8.2 and > + later. > + > + BEGIN; > + CREATE TEMP TABLE a_list_COUNTRIES AS > + SELECT * FROM country WHERE country_name LIKE 'A%'; > + COPY a_list_countries TO '/usr1/proj/bray/sql/a_list_countries.copy'; > + ROLLBACK; > + VACUUM; > + > + > + > + > Here is a sample of data suitable for copying into a table from > STDIN: > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Have you searched our list archives? > > http://archives.postgresql.org -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461