From: Markus Schaber <schabi@logix-tt.com>
To: Antal Attila <atesz@ritek.hu>
Cc: pgsql-sql@postgresql.org
Subject: Re: VIEWs and TEMP tables problem
Date: Thu, 16 Feb 2006 13:13:18 +0100
Message-ID: <43F46C5E.8090806@logix-tt.com> (raw)
In-Reply-To: <43F4617E.9060708@ritek.hu>
References: <43F4617E.9060708@ritek.hu>
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/83fa0053cad...
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: schabi@logix-tt.com, atesz@ritek.hu
Subject: Re: VIEWs and TEMP tables problem
In-Reply-To: <43F46C5E.8090806@logix-tt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox