X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0C21BD1B56B for ; Mon, 18 Aug 2003 16:43:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 29432-09 for ; Mon, 18 Aug 2003 13:43:31 -0300 (ADT) Received: from unimm.unisoftbg.com (mail.unisoftbg.com [194.12.229.207]) by svr1.postgresql.org (Postfix) with ESMTP id 977D0D1B89E for ; Mon, 18 Aug 2003 13:43:27 -0300 (ADT) Received: (qmail 3307 invoked by uid 507); 18 Aug 2003 11:19:13 -0000 Received: from unknown (HELO t1.unisoftbg.com) (pginfo%t1.unisoftbg.com@194.12.229.193) by 0 with SMTP; 18 Aug 2003 11:19:13 -0000 Message-ID: <3F40A623.FF953D8E@t1.unisoftbg.com> Date: Mon, 18 Aug 2003 12:10:43 +0200 From: pginfo X-Mailer: Mozilla 4.03 [en] (Win95; I) MIME-Version: 1.0 To: "pgsql-performance@postgresql.org" Subject: bad join preformance Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/286 X-Sequence-Number: 3102 Hi , I am using pg 7.3.3 on RH 7.3, dual Athlon 1 GB RAM. I have 2 tables a_acc and a_vid_doc (all PK are int). sizes: select count(IDS) from a_acc; count --------- 1006772 select count(IDS) from a_vid_doc; count ------- 25 I have problem with the join ot this tables. I tryed this examples: explain analyze select G.IDS from A_ACC G join A_VID_DOC VD ON(G.IDS_VID_DOC=VD.IDS) WHERE G.IDS = 1338673 ; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Merge Join (cost=1.83..1.97 rows=1 width=12) (actual time=40.78..2085.82 rows=1 loops=1) Merge Cond: ("outer".ids_vid_doc = "inner".ids) -> Index Scan using i_a_acc_ids_vid_doc on a_acc g (cost=0.00..43706.42 rows=1 width=8) (actual time=40.52..2085.55 rows=1 loops=1) Filter: (ids = 1338673) -> Sort (cost=1.83..1.89 rows=25 width=4) (actual time=0.22..0.22 rows=25 loops=1) Sort Key: vd.ids -> Seq Scan on a_vid_doc vd (cost=0.00..1.25 rows=25 width=4) (actual time=0.05..0.07 rows=25 loops=1) Total runtime: 2085.93 msec (8 rows) and explain analyze select G.IDS from A_ACC G , A_VID_DOC VD where G.IDS_VID_DOC=VD.IDS and G.IDS = 1338673 ; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------- Merge Join (cost=1.83..1.97 rows=1 width=12) (actual time=40.91..2099.13 rows=1 loops=1) Merge Cond: ("outer".ids_vid_doc = "inner".ids) -> Index Scan using i_a_acc_ids_vid_doc on a_acc g (cost=0.00..43706.42 rows=1 width=8) (actual time=40.65..2098.86 rows=1 loops=1) Filter: (ids = 1338673) -> Sort (cost=1.83..1.89 rows=25 width=4) (actual time=0.22..0.22 rows=25 loops=1) Sort Key: vd.ids -> Seq Scan on a_vid_doc vd (cost=0.00..1.25 rows=25 width=4) (actual time=0.05..0.07 rows=25 loops=1) Total runtime: 2099.24 msec (8 rows)