X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2FC5A475F54 for ; Tue, 25 Feb 2003 05:08:47 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 61442-01 for ; Tue, 25 Feb 2003 05:08:36 -0500 (EST) Received: from MX2.estpak.ee (mta2.mail.neti.ee [194.126.101.111]) by postgresql.org (Postfix) with ESMTP id D6DC0475D70 for ; Tue, 25 Feb 2003 01:37:42 -0500 (EST) Received: from tmkodu (80-235-62-66-dsl.trt.estpak.ee [80.235.62.66]) by MX2.estpak.ee (Postfix) with SMTP id 1FF9073578; Tue, 25 Feb 2003 08:36:22 +0200 (EET) Message-ID: <002601c2dc99$056ef520$0100a8c0@kodunet.ee> From: "Tambet Matiisen" To: "Tambet Matiisen" , , "Rafal Kedziorski" References: <5.2.0.9.0.20030224004643.01b21e08@mail.polonium.de> Subject: Re: good style? Date: Tue, 25 Feb 2003 08:42:09 +0200 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.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200303/28 X-Sequence-Number: 12068 ----- Original Message ----- From: "Rafal Kedziorski" To: "Tambet Matiisen" ; Sent: Monday, February 24, 2003 1:51 AM Subject: Re: [SQL] good style? > [snip] > > > original: > > Merge Join (cost=728.47..820.47 rows=1000 width=366) > ... > > > 1st join: > Merge Join (cost=3042.29..3184.29 rows=5000 width=366) > ... > > > 2nd join: > Merge Join (cost=3042.29..3184.29 rows=5000 width=366) > ... > > > have I post thic correctly using JOIN? > > Optimizer expects the original query to return 1000 rows, while others are expected to return 5000 rows. I compared the original query with others, but didn't see any difference at first sight. I don't know, if the expected row count depends on execution path in Postgres. You can look at explain output of original query and imitate the join order chosen by optimizer by JOINs, and then compare costs. What are the real-world timings? And do these queries actually return the same result? If you calculate cost for fetching one row, then 3184,29 / 5000 = 0,636858, while 820.47 / 1000 = 0,82047. So maybe it's not that bad at all. Tambet