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 ---------------------------(end of broadcast)--------------------------- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match