X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 78E135321F for ; Thu, 24 Mar 2005 19:37:23 +0000 (GMT) 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 39866-10 for ; Thu, 24 Mar 2005 19:37:16 +0000 (GMT) Received: from happy.onesystem.ca (happy.onesystem.ca [205.206.61.17]) by svr1.postgresql.org (Postfix) with ESMTP id 9D34652D93 for ; Thu, 24 Mar 2005 19:37:16 +0000 (GMT) Received: from elb_lx.onesystem.ca ([10.1.1.50]) by happy.onesystem.ca with asmtp (Exim 4.14) id 1DEY8q-0002YN-Ox; Thu, 24 Mar 2005 12:37:16 -0700 Message-ID: <424316EC.2090207@onesystem.com> Date: Thu, 24 Mar 2005 12:37:16 -0700 From: Edmund Bacon User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sean Davis Cc: PostgreSQL SQL Subject: Re: Self-referencing table question References: <0af8c6d3baaf3d4a6d918df294019507@mail.nih.gov> <7e154914b76fb1a7c55912b621400860@mail.nih.gov> <4240874E.2080301@archonet.com> <4242E732.3050600@onesystem.com> <1303f92d183bfd2ff7c522d4ad5afde8@mail.nih.gov> <424302D1.7000602@onesystem.com> <62cd9fffe536b0665a1da78478c4ec20@mail.nih.gov> In-Reply-To: <62cd9fffe536b0665a1da78478c4ec20@mail.nih.gov> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200503/331 X-Sequence-Number: 20810 Sean Davis wrote: > Nice. Thanks for doing my work for me! Yeah, well put it down to a certain amount of curiosity and a slack period at work ... > I guess I will have to think about it more seriously. > > It could be a slight bit complicated because my code is running under > mod_perl, so connections are cached. As I understand it, the temp > table will stick around, so I will have to be careful to explicitly > drop it if I don't want it to persist? I'm guessing so. However you could put everything in a transaction and use CREATE TEMP TABLE ... ON COMMIT DROP, and use INSERT INTO rather than SELECT INTO. The speed should be about equivalent - but you'd have to test to make sure. > Also each table will need a unique name (I have a session_id I can > use), as it is possible that multiple temp tables will exist and be > visible to each other? Each session (connection in your case?) has it's own temporary table space, so you shouldn't have to worry about that. > > > Thanks again, > Sean > -- Edmund Bacon