X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 5A1BE9F9AFD for ; Thu, 4 May 2006 11:15:42 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 56595-07 for ; Thu, 4 May 2006 11:15:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 8049A9F9B76 for ; Thu, 4 May 2006 11:15:27 -0300 (ADT) Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) by svr4.postgresql.org (Postfix) with ESMTP id 2213D5B681C for ; Thu, 4 May 2006 14:15:25 +0000 (GMT) Received: from localhost (localhost.localdomain [127.0.0.1]) by pjetlic.mobart.hr (Postfix) with ESMTP id CCD1917D71; Thu, 4 May 2006 16:15:16 +0200 (CEST) Received: from pjetlic.mobart.hr ([127.0.0.1]) by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 10752-01-3; Thu, 4 May 2006 16:15:16 +0200 (CEST) Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) by pjetlic.mobart.hr (Postfix) with ESMTP id B3B0717D60; Thu, 4 May 2006 16:15:16 +0200 (CEST) Subject: Re: Lot'sa joins - performance tip-up, please? From: Mario Splivalo To: Dave Dutcher , pgsql-performance@postgresql.org In-Reply-To: <003001c66ec5$205a0160$8300a8c0@tridecap.com> References: <003001c66ec5$205a0160$8300a8c0@tridecap.com> Content-Type: text/plain Date: Thu, 04 May 2006 16:15:13 +0200 Message-Id: <1146752113.8538.22.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by OpenSource AV+AS Mail Server X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/204 X-Sequence-Number: 18991 On Wed, 2006-05-03 at 10:20 -0500, Dave Dutcher wrote: > > -> Nested Loop (cost=0.00..176144.30 rows=57925 width=26) > > (actual time=68.322..529472.026 rows=57925 loops=1) > > -> Seq Scan on ticketing_codes_played > > (cost=0.00..863.25 rows=57925 width=8) (actual time=0.042..473.881 > > rows=57925 loops=1) > > -> Index Scan using ticketing_codes_pk on > > ticketing_codes (cost=0.00..3.01 rows=1 width=18) (actual > > time=9.102..9.108 rows=1 loops=57925) > > Index Cond: (ticketing_codes.code_id = > > "outer".code_id) > > Total runtime: 542000.093 ms > > (27 rows) > > > > > > I'll be more than happy to provide any additional information > > that I may > > be able to gather. I'd be most happy if someone would scream something > > like "four joins, smells like a poor design" because design > > is poor, but > > the system is in production, and I have to bare with it. > > > It looks like that nested loop which is joining ticketing_codes_played > to ticketing_codes is the slow part. I'm curious how many rows are in > the ticketing_codes table? > > Four or five joins does not seem like a lot to me, but it can be slow if > you are joining big tables with other big tables. Ticketing_codes table has 11000000 records, and it's expected to grow. I tried playing with JOIN order as Tom suggested, but performance is the same. Mario