X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id DCD129FB345 for ; Wed, 16 Aug 2006 15:02:35 -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 66806-04 for ; Wed, 16 Aug 2006 15:02:26 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) by postgresql.org (Postfix) with ESMTP id A6DC39FB30D for ; Wed, 16 Aug 2006 15:02:26 -0300 (ADT) Received: from [127.0.0.1] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) by olive.qinip.net (Postfix) with ESMTP id 8E793181F6; Wed, 16 Aug 2006 20:02:21 +0200 (MEST) Message-ID: <44E35DB0.8050109@tweakers.net> Date: Wed, 16 Aug 2006 20:02:24 +0200 From: Arjen van der Meijden User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: Peter Hardman CC: pgsql-performance@postgresql.org Subject: Re: PostgreSQL runs a query much slower than BDE and MySQL References: <44E35A5D.19933.35F376@peter.ssbg.zetnet.co.uk> In-Reply-To: <44E35A5D.19933.35F376@peter.ssbg.zetnet.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 0633-2, 16-08-2006), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.184 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200608/269 X-Sequence-Number: 20454 On 16-8-2006 18:48, Peter Hardman wrote: > Using identically structured tables and the same primary key, if I run this on > Paradox/BDE it takes about 120ms, on MySQL (5.0.24, local server) about 3ms, > and on PostgresSQL (8.1.3, local server) about 1290ms). All on the same > Windows XP Pro machine with 512MB ram of which nearly half is free. Is that with or without query caching? I.e. can you test it with SELECT SQL_NO_CACHE ... ? In a read-only environment it will still beat PostgreSQL, but as soon as you'd get a read-write environment, MySQL's query cache is of less use. So you should compare both the cached and non-cached version, if applicable. Besides that, most advices on this list are impossible without the result of 'explain analyze', so you should probably get that as well. I'm not sure whether this is the same query, but you might want to try: SELECT DISTINCT f1.regn_no, f1.transfer_date as date_in FROM SHEEP_FLOCK f1 WHERE f1.flock_no = '1359' AND f1.transfer_date = (SELECT MAX(f.transfer_date) FROM SHEEP_FLOCK f WHERE regn_no = f1.regn_no) And you might need an index on (regn_no, transfer_date) and/or one combined with that flock_no. Best regards, Arjen