X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6B2A232A0D0 for ; Thu, 7 Oct 2004 16:35:46 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 06019-02 for ; Thu, 7 Oct 2004 15:35:37 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id A9C3A32A3D2 for ; Thu, 7 Oct 2004 16:35:37 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i97FZZS9029075; Thu, 7 Oct 2004 11:35:35 -0400 (EDT) To: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= Cc: pgsql-performance@postgresql.org Subject: Re: sequential scan on select distinct In-reply-to: References: <200410061130.58625.ole@freiheit.com> <874ql7ztnb.fsf@stark.xeocode.com> <29194.1097091506@sss.pgh.pa.us> Comments: In-reply-to =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= message dated "Thu, 07 Oct 2004 14:01:13 +0200" Date: Thu, 07 Oct 2004 11:35:34 -0400 Message-ID: <29074.1097163334@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/81 X-Sequence-Number: 8557 =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= writes: > Present state is that DISTINCT and UNION are slow with or without using > the GROUP BY trick. Including the index skip scan in the planning options > would only happen when appropriate cases are detected. This detection > would be very fast. You have no basis whatever for making that last assertion; and since it's the critical point, I don't intend to let you slide by without backing it up. I think that looking for relevant indexes would be nontrivial; the more so in cases like you've been armwaving about just above, where you have to find a relevant index for each of several subqueries. The fact that the optimization wins a lot when it wins is agreed, but the time spent trying to apply it when it doesn't work is a cost that has to be set against that. I don't accept your premise that every query for which skip-index isn't relevant is so slow that planning time does not matter. regards, tom lane