Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 733BF4759EC for ; Tue, 30 Apr 2002 17:30:57 -0400 (EDT) Received: from beamish.nsd.ca (unknown [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id 0BD0A4759A6 for ; Tue, 30 Apr 2002 17:30:56 -0400 (EDT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id RAA25237; Tue, 30 Apr 2002 17:30:55 -0400 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma025235; Tue, 30 Apr 02 17:30:39 -0400 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id RAA15398; Tue, 30 Apr 2002 17:30:39 -0400 Message-ID: <3CCF0DFE.1B0E583D@nsd.ca> Date: Tue, 30 Apr 2002 17:34:54 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.9-31 i686) X-Accept-Language: en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-sql@postgresql.org Subject: Re: performance on update table from a join References: <20020430181519.5E5D9475985@postgresql.org> <21326.1020191577@sss.pgh.pa.us> <21413.1020192353@sss.pgh.pa.us> <21990.1020197073@sss.pgh.pa.us> <3CCEFFDC.516131CC@nsd.ca> <753.1020199796@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200204/369 X-Sequence-Number: 7633 Fair enough. nsd=# explain update c set newroute = r.route, route = r.routeno, street = trim( lpad( r.seqno, 4, '0')), exchangeno = r.exchangeno nsd-# from routes r, rs s where ( c.stname, c.municipality) = (s.oldstname, s.oldmuni) and nsd-# (s.exchangeno, s.stname, s.municipality) = ( r.exchangeno, r.street, r.municipality) and nsd-# r.fromno <= c.civic and c.civic <= r.tono and (r.parity = c.civic%2 or r.parity = -1); NOTICE: QUERY PLAN: Hash Join (cost=1943.04..136718.39 rows=100 width=660) -> Seq Scan on c (cost=0.00..112409.04 rows=1156604 width=519) -> Hash (cost=1939.63..1939.63 rows=1365 width=141) -> Merge Join (cost=0.00..1939.63 rows=1365 width=141) -> Index Scan using routes_str_mun on routes r (cost=0.00..1053.46 rows=13928 width=77) -> Index Scan using rs_stname on rs s (cost=0.00..704.11 rows=10942 width=64) EXPLAIN I have also the following indecies that are ot being used: create index routes_ex_str_mun on routes( exchangeno, street, municipality); create index rs_ostr_omun on rs( oldstname, oldmuni); Tom Lane wrote: > > Jean-Luc Lachance writes: > > Hash Join (cost=109.44..118460.53 rows=1 width=857) > > -> Seq Scan on c (cost=0.00..112409.04 rows=1156604 width=519) > > -> Hash (cost=109.44..109.44 rows=1 width=338) > > -> Merge Join (cost=0.00..109.44 rows=1 width=338) > > -> Index Scan using routes_str_mun on routes r (cost=0.00..52.00 rows=1000 width=152) > > -> Index Scan using rs_stname on rs s (cost=0.00..52.00 rows=1000 width=186) > > Have you vacuum analyzed routes and rs? I always disbelieve any plan > with 'rows=1000' in it, because I know that's the default assumption > when no stats are available... > > regards, tom lane