About index for temporay table in a plpgsql function - Mailing list pgsql-general

From Emi Lu
Subject About index for temporay table in a plpgsql function
Date
Msg-id 4419E362.4030303@encs.concordia.ca
Whole thread Raw
Responses Re: About index for temporay table in a plpgsql function
List pgsql-general
Hello,

A question about index for temporary table.

Postgresql 8.0.1, in a pl/pgsql function:
begin
...
-- Part I
create temporal table t1 as ((select ... from .. left join ..... where
... ) union (select .. from ... left join ... where ...  ));
create index idx_t1_cols on t1(col1, col2) tablespace ts1;

...
-- Part II
insert into tableX
(
  select ...
  from tableY
  left join t1 using (col1, col2)
  where ... ...
)
...
end;

In the above example, the index for t1 can speed up the left join query
in part II (although, there is no analyze done after the creation of
index), right?

The temporary table will be dropped automatically at the end of the
function, right?
By the way, is there anythings need to pay especially attention about
temporary table under a function please?

Thanks a lot,
Ying



pgsql-general by date:

Previous
From: "Stephen Slezak"
Date:
Subject: Re: PostgreSQL Knowledge Base
Next
From: "Brandon Keepers"
Date:
Subject: Re: Relation 'pg_largeobject' does not exist