X-Original-To: pgsql-general-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 339659FB288 for ; Thu, 3 Aug 2006 06:00:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 09761-09 for ; Thu, 3 Aug 2006 09:00:08 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 466FC9FB282 for ; Thu, 3 Aug 2006 06:00:08 -0300 (ADT) Received: from mainbox.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 3DDDB74C73; Thu, 3 Aug 2006 10:00:05 +0100 (BST) Received: from [192.168.1.17] (client17.office.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id D03A22DD3E; Thu, 3 Aug 2006 10:00:04 +0100 (BST) Message-ID: <44D1BB14.1020000@archonet.com> Date: Thu, 03 Aug 2006 10:00:04 +0100 From: Richard Huxton User-Agent: Thunderbird 1.5.0.5 (X11/20060719) MIME-Version: 1.0 To: Christian Rengstl Cc: Hakan Kocaman , pgsql-general@postgresql.org Subject: Re: Query performance References: <84AAD313D71B1D4F9EE20E739CC3B6ED01161806@ATLANTIK-CL.intern.digame.de> <44D1D45E.0AD0.0080.0@klinik.uni-regensburg.de> In-Reply-To: <44D1D45E.0AD0.0080.0@klinik.uni-regensburg.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.951 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: *** X-Archive-Number: 200608/150 X-Sequence-Number: 98922 Christian Rengstl wrote: > Hi, > > the complete query is the one i posted, but here comes the schema for mytable: > entry_no int8 NOT NULL DEFAULT nextval('entry_no_seq''::regclass), > pid varchar(15) NOT NULL, > crit varchar(13) NOT NULL, > val1 varchar(1), > val2 varchar(1), > aendat text, > aennam varchar(8), > CONSTRAINT "PK_ENTRY" PRIMARY KEY (entry_no) > > myCritTable: > crit varchar(13) NOT NULL, > chr int2, > aendat timestamp, > CONSTRAINT pk_crit_master PRIMARY KEY (crit) Still doesn't match the EXPLAIN output - where's snp_id? Where's table test2? > My server is 8.1.4. As a matter of fact, i have no idea where the text > type comes from, because as you can see from above there are only > varchar with maximum 15 characters. PG is casting it to text. There's no real difference between the types (other than the size limit) and it's not expensive. > "Hakan Kocaman" wrote on 08/03/06 10:34 am: >> Hi, >> >> can you post the complete query,schema- and >> table-definition,server-version etc. ? >> This will help to identity the main problem. >> >> So at the moment i'm just guessing: >> >> Hash Cond: (("outer".snp_id)::text = ("inner".snp_id)::text) >> -> Bitmap Heap Scan on test2 (cost=232.92..132766.66 rows=37120 >> width=23) >> (actual time=291.600..356707.737 rows=37539 loops=1) >> This part is very expensive, but i got no clue why. Yep, it looks like the "Bitmap Heap Scan" is at the heart of this. You might want to increase work_mem, it could be that the bitmap is spilling to disk (which is much slower than keeping it all in RAM) http://www.postgresql.org/docs/8.1/static/runtime-config-resource.html#RUNTIME-CONFIG-RESOURCE-MEMORY If it's still at 1MB (1024), try 5MB, 10MB, 50MB and see what happens. -- Richard Huxton Archonet Ltd