X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7B078DA05D for ; Tue, 4 Oct 2005 16:23:22 -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 41708-04 for ; Tue, 4 Oct 2005 19:23:18 +0000 (GMT) Received: from guinness.cs.stevens.edu (guinness.cs.stevens-tech.edu [155.246.89.8]) by svr1.postgresql.org (Postfix) with ESMTP id 5DC41DA060 for ; Tue, 4 Oct 2005 16:23:17 -0300 (ADT) Received: from long-trail.cs.stevens.edu (long-trail.cs.stevens-tech.edu [155.246.89.41]) by guinness.cs.stevens.edu (Postfix) with ESMTP id 49ADB141677 for ; Tue, 4 Oct 2005 15:23:16 -0400 (EDT) Received: by long-trail.cs.stevens.edu (Postfix, from userid 4405) id D06432380A0; Tue, 4 Oct 2005 15:23:15 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by long-trail.cs.stevens.edu (Postfix) with ESMTP id 9D7B222641F for ; Tue, 4 Oct 2005 15:23:15 -0400 (EDT) Date: Tue, 4 Oct 2005 15:23:15 -0400 (EDT) From: Yasir Malik X-X-Sender: ymalik@long-trail.cs.stevens-tech.edu To: PostgreSQL Subject: Re: using pg_tables and tablename in queries In-Reply-To: Message-ID: References: <9420.1128445291@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/8 X-Sequence-Number: 22861 > The current behavior is by design. > > We use the table as a logging repository. It can get very large 250 000 > records. Because of the large number of records that we have in the table we > found it was much faster to perform inserts on a smaller table. Our current > system rolls the tables over every 12 hours or so, creating a new table with > the following behavior: > > CREATE TABLE mytable_temp {...} > > ALTER TABLE mytable RENAME TO mytable_back_datetime; > ALTER TABLE mytable_temp RENAME TO mytable; > > I want to join the mytable_back_datetime tables together in order to perform > queries against my huge set of data to generate some reports. I'm probably > going to create a temporary table with a few indexes to make the reports run > faster... however I need to join the tables all together first. > I would create a function that creates a string with a query that includes all the tables you need, and call execute on the string. You would loop through the all tables from pg_tables and keep on appending the table name you need. Regards, Yasir