Re: Performance question related with temporary tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Vilson farias" <vilson(dot)farias(at)digitro(dot)com(dot)br>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Performance question related with temporary tables
Date: 2002-05-08 14:17:15
Message-ID: 1901.1020867435@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

"Vilson farias" <vilson(dot)farias(at)digitro(dot)com(dot)br> writes:
> I've been testing some queries and I have a question : Is there a way to =
> put a index in a temporary table?

You just do it.

test72=# create temp table foo (f1 int primary key);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'foo_pkey' for table 'foo'
CREATE
test72=# explain select * from foo where f1 = 42;
NOTICE: QUERY PLAN:
Index Scan using foo_pkey on foo (cost=0.00..4.82 rows=1 width=4)

or if you prefer

test72=# drop table foo;
DROP
test72=# create temp table foo (f1 int);
CREATE
test72=# create index fooi on foo(f1);
CREATE
test72=# explain select * from foo where f1 = 42;
NOTICE: QUERY PLAN:
Index Scan using fooi on foo (cost=0.00..17.07 rows=5 width=4)

It's not any different from working with a permanent table...

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Vilson farias 2002-05-08 14:34:12 Re: Performance question related with temporary tables
Previous Message Bojan Belovic 2002-05-08 14:00:05 Re: db recovery (FATAL 2)