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 0EC8253446 for ; Thu, 24 Mar 2005 19:01:24 +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 30271-06 for ; Thu, 24 Mar 2005 19:01:15 +0000 (GMT) Received: from mx5.net.nih.gov (mx5.net.nih.gov [165.112.130.36]) by svr1.postgresql.org (Postfix) with ESMTP id 22AEC52D93 for ; Thu, 24 Mar 2005 19:01:14 +0000 (GMT) Received: from mx5.net.nih.gov (localhost [127.0.0.1]) by mx5.net.nih.gov (8.12.10/8.11.6) with ESMTP id j2OJ1Eas022664 for ; Thu, 24 Mar 2005 14:01:14 -0500 Received: from [128.231.145.14] (holmes.nhgri.nih.gov [128.231.145.14]) by mx5.net.nih.gov (8.12.10/8.11.6) with ESMTP id j2OJ1EKd022659; Thu, 24 Mar 2005 14:01:14 -0500 In-Reply-To: <424302D1.7000602@onesystem.com> 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> Mime-Version: 1.0 (Apple Message framework v619.2) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <62cd9fffe536b0665a1da78478c4ec20@mail.nih.gov> Content-Transfer-Encoding: 7bit Cc: PostgreSQL SQL From: Sean Davis Subject: Re: Self-referencing table question Date: Thu, 24 Mar 2005 14:01:13 -0500 To: Edmund Bacon X-Mailer: Apple Mail (2.619.2) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/330 X-Sequence-Number: 20809 On Mar 24, 2005, at 1:11 PM, Edmund Bacon wrote: > Sean Davis wrote: > >> Thanks. I thought about that a bit and it seems like it is highly >> likely to be expensive for a single query (though I should probably >> try it at some point). If I do find myself reformatting results >> after response to user input (i.e., reusing the query), though, then >> your solution is likely to be very useful. >> > > > Note that the subselect version takes about 10 times as long as the > temptable version, and does not seem to be dependent on what data > might be cached. >>> Nice. Thanks for doing my work for me! 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? 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? Thanks again, Sean