X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id B7D409DC9A7 for ; Thu, 16 Feb 2006 08:50:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85160-01 for ; Thu, 16 Feb 2006 08:50:52 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) by postgresql.org (Postfix) with ESMTP id E799C9DC83D for ; Thu, 16 Feb 2006 08:50:46 -0400 (AST) Received: from kingfisher.intern.logix-tt.com (Me829.m.pppool.de [89.49.232.41]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 0FBBC244080; Thu, 16 Feb 2006 13:50:53 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id D0C801816770F; Thu, 16 Feb 2006 13:13:19 +0100 (CET) Message-ID: <43F46C5E.8090806@logix-tt.com> Date: Thu, 16 Feb 2006 13:13:18 +0100 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Antal Attila Cc: pgsql-sql@postgresql.org Subject: Re: VIEWs and TEMP tables problem References: <43F4617E.9060708@ritek.hu> In-Reply-To: <43F4617E.9060708@ritek.hu> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.121 required=5 tests=[AWL=0.121] X-Spam-Score: 0.121 X-Spam-Level: X-Archive-Number: 200602/203 X-Sequence-Number: 24213 Hi, Antal, Antal Attila wrote: > CREATE VIEW a_view AS SELECT * FROM a JOIN actual_code AC ON (a.code = > AC.code); Here, you bind the View to the permanent table. > CREATE TEMP TABLE actual_code AS SELECT 23::INT4 AS code; And here you create the temp table that will hide the permanent table. > I read the temporally table definition in the documentation > (http://www.postgresql.org/docs/8.1/interactive/sql-createtable.html) > and I concluded it should be working. I would not think so, as it states "unless they are referenced with schema-qualified names". So the permanent table is not removed, only hidden in the default (non-qualified) name space. Views don't look up the tables by name. Views bind to the table via internal ids, and this binding is strong enough to survive even a table rename, still referencing the same table. > Is it BUG, or FEATURE? Has anybody got good ideas for solve this problem? It is a feature. > This construction came to my mind, because I tried to solve my another > question: > http://groups.google.co.hu/group/pgsql.performance/browse_thread/thread/c7aec005f4a1f3eb/83fa0053cad33dea Maybe you try: CREATE VIEW ab_view AS SELECT a.id AS id, a.userid AS userid, a.col AS col_a, b.col AS col_b FROM a LEFT JOIN b ON (a.id = b.a_id AND a.userid=b.userid); EXPLAIN ANALYSE SELECT * FROM ab_view WHERE userid = 23 AND col_a LIKE 's%' ORDER BY col_b LIMIT 10 OFFSET 10; HTH, Markus -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org