From vilson.farias@digitro.com.br Wed May 8 13:54:49 2002 Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id EB81847594B for ; Wed, 8 May 2002 09:54:49 -0400 (EDT) Received: from ias.digitro.com.br (unknown [200.247.100.134]) by postgresql.org (Postfix) with ESMTP id 948B24758E1 for ; Wed, 8 May 2002 09:51:41 -0400 (EDT) Received: from serverdgt.daf.digitro.com.br ([192.2.2.10]) by ias.digitro.com.br (8.11.1/8.11.1) with ESMTP id g48D8ww15897 for ; Wed, 8 May 2002 10:08:58 -0300 Received: from dgtac ([192.168.160.152]) by serverdgt.daf.digitro.com.br (8.11.1/8.8.7) with SMTP id g48DAx030363 for ; Wed, 8 May 2002 10:10:59 -0300 Message-ID: <002f01c1f691$8fcea560$98a0a8c0@dgtac> From: "Vilson farias" To: Subject: Performance question related with temporary tables Date: Wed, 8 May 2002 10:09:16 -0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002C_01C1F678.691A6350" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Archive-Number: 200205/63 X-Sequence-Number: 4238 This is a multi-part message in MIME format. ------=_NextPart_000_002C_01C1F678.691A6350 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Greetings, =20=20 I've been testing some queries and I have a question : Is there a way to = put a index in a temporary table? I have a query that does a join from a ta= ble and a temporary table and this join is done with a very long sequencial= scan because the temporary table aparently hasn't any index. I would like = to know how can I deal with this kind of situation.=20 Best Regards, ---------------------------------------------------------------------------= ----- Jos=E9 Vilson de Mello de Farias Software Engineer D=EDgitro Tecnologia Ltda - www.digitro.com.br APC - Customer Oriented Applications E-mail: vilson.farias@digitro.com.br Tel.: +55 48 281 7158=20 ICQ 11866179 ------=_NextPart_000_002C_01C1F678.691A6350 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Greetings,
 
 
  I've been testing some queri= es and I=20 have a question : Is there a way to put a index in a temporary table? I hav= e a=20 query that does a join from a table and a temporary table and this join is = done=20 with a very long sequencial scan because the temporary table aparently hasn= 't=20 any index. I would like to know how can I deal with this kind of situation.= =20
 
Best Regards,
 
------------------------------------------------------------------= --------------
Jos=E9=20 Vilson de Mello de Farias
Software Engineer
 
D=EDgitro Tecnologia Ltda - www.digitro.com.br
APC - Customer= =20 Oriented Applications
E-mail: vilson.farias@digitro.com.br
Tel.:=20 +55 48 281 7158
ICQ 11866179
------=_NextPart_000_002C_01C1F678.691A6350-- From tgl@sss.pgh.pa.us Wed May 8 14:32:42 2002 Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 6D660475B6F for ; Wed, 8 May 2002 10:32:42 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id A8D5C4761DF for ; Wed, 8 May 2002 10:17:29 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g48EHFv01904; Wed, 8 May 2002 10:17:15 -0400 (EDT) To: "Vilson farias" Cc: pgsql-admin@postgresql.org Subject: Re: Performance question related with temporary tables In-reply-to: <002f01c1f691$8fcea560$98a0a8c0@dgtac> References: <002f01c1f691$8fcea560$98a0a8c0@dgtac> Comments: In-reply-to "Vilson farias" message dated "Wed, 08 May 2002 10:09:16 -0300" Date: Wed, 08 May 2002 10:17:15 -0400 Message-ID: <1901.1020867435@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200205/64 X-Sequence-Number: 4239 "Vilson farias" 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 From vilson.farias@digitro.com.br Wed May 8 15:02:32 2002 Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id B1E6B476C40 for ; Wed, 8 May 2002 11:02:32 -0400 (EDT) Received: from ias.digitro.com.br (unknown [200.247.100.134]) by postgresql.org (Postfix) with ESMTP id 168B64762A4 for ; Wed, 8 May 2002 10:34:21 -0400 (EDT) Received: from serverdgt.daf.digitro.com.br ([192.2.2.10]) by ias.digitro.com.br (8.11.1/8.11.1) with ESMTP id g48EXuw18647 for ; Wed, 8 May 2002 11:33:56 -0300 Received: from dgtac ([192.168.160.152]) by serverdgt.daf.digitro.com.br (8.11.1/8.8.7) with SMTP id g48EZv017329 for ; Wed, 8 May 2002 11:35:57 -0300 Message-ID: <006501c1f69d$6d6357d0$98a0a8c0@dgtac> From: "Vilson farias" To: References: <002f01c1f691$8fcea560$98a0a8c0@dgtac> <1901.1020867435@sss.pgh.pa.us> Subject: Re: Performance question related with temporary tables Date: Wed, 8 May 2002 11:34:12 -0300 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Archive-Number: 200205/67 X-Sequence-Number: 4242 > You just do it. Great, it's so simple... thanks Tom. I just have another two questions : Is the index automaticly removed when connection is closed? The index is visible only in the actual session, am I right? Best Regards from Brazil!! From tgl@sss.pgh.pa.us Wed May 8 21:13:36 2002 Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id AAAE54762C1 for ; Wed, 8 May 2002 17:13:36 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 5E01047620D for ; Wed, 8 May 2002 16:37:41 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g48KbVW12312; Wed, 8 May 2002 16:37:31 -0400 (EDT) To: "Vilson farias" Cc: pgsql-admin@postgresql.org Subject: Re: Performance question related with temporary tables In-reply-to: <006501c1f69d$6d6357d0$98a0a8c0@dgtac> References: <002f01c1f691$8fcea560$98a0a8c0@dgtac> <1901.1020867435@sss.pgh.pa.us> <006501c1f69d$6d6357d0$98a0a8c0@dgtac> Comments: In-reply-to "Vilson farias" message dated "Wed, 08 May 2002 11:34:12 -0300" Date: Wed, 08 May 2002 16:37:31 -0400 Message-ID: <12309.1020890251@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200205/69 X-Sequence-Number: 4244 "Vilson farias" writes: >> You just do it. > Great, it's so simple... thanks Tom. > I just have another two questions : > Is the index automaticly removed when connection is closed? > The index is visible only in the actual session, am I right? Yup. An index on a temp table is temp in just the same way as the temp table itself. There's no "TEMP" option in CREATE INDEX, it's just done that way for you. (Any toast table needed is also handled correctly, although the mechanism is slightly different.) regards, tom lane