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 47CABD1B193 for ; Fri, 18 Jun 2004 20:06:34 -0300 (ADT) 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 57564-02 for ; Fri, 18 Jun 2004 23:06:32 +0000 (GMT) Received: from web25101.mail.ukl.yahoo.com (web25101.mail.ukl.yahoo.com [217.12.10.49]) by svr1.postgresql.org (Postfix) with SMTP id A6D52D1B18F for ; Fri, 18 Jun 2004 20:06:27 -0300 (ADT) Message-ID: <20040618230629.47789.qmail@web25101.mail.ukl.yahoo.com> Received: from [217.158.107.104] by web25101.mail.ukl.yahoo.com via HTTP; Sat, 19 Jun 2004 00:06:29 BST Date: Sat, 19 Jun 2004 00:06:29 +0100 (BST) From: =?iso-8859-1?q?Gary=20Cowell?= Subject: Re: Major differences between oracle and postgres performance - what can I do ? To: pgsql-performance@postgresql.org In-Reply-To: <25464.1087591637@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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: 200406/205 X-Sequence-Number: 7263 --- Tom Lane wrote: > =?iso-8859-1?q?Gary=20Cowell?= > writes: > > So it seems the idea that oracle is dropping > duplicate > > rows prior to the sort when using distinct may > indeed > > be the case. > > Okay. We won't have any short-term solution for > making DISTINCT do that, > but if you are on PG 7.4 you could get the same > effect from using > GROUP BY: instead of > select distinct version from vers where version is > not null > try > select version from vers where version is not null > group by version > You should get a HashAggregate plan out of that, and > I'd think it'd be > pretty quick when there are not many distinct values > of version. > Yeah out of the half million rows there are only ever going to be 500 or so distinct values. I do indeed get such a plan. It's much faster that way. Down to 16 seconds. I'll get the chap to rewrite his app to use group by instead of distinct. Thanks (everyone) for the top class help! ___________________________________________________________ALL-NEW Yahoo! Messenger - sooooo many all-new ways to express yourself http://uk.messenger.yahoo.com