From: Tom Lane <tgl@sss.pgh.pa.us>
To: Vilson farias <vilson.farias@digitro.com.br>
Cc: pgsql-admin@postgresql.org
Subject: Re: Performance question related with temporary tables
Date: Wed, 08 May 2002 10:17:15 -0400
Message-ID: <1901.1020867435@sss.pgh.pa.us> (raw)
In-Reply-To: <002f01c1f691$8fcea560$98a0a8c0@dgtac>
References: <002f01c1f691$8fcea560$98a0a8c0@dgtac>
"Vilson farias" <vilson.farias@digitro.com.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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, vilson.farias@digitro.com.br
Subject: Re: Performance question related with temporary tables
In-Reply-To: <1901.1020867435@sss.pgh.pa.us>
References: <002f01c1f691$8fcea560$98a0a8c0@dgtac> <1901.1020867435@sss.pgh.pa.us>
* 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