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 A9C729FB282 for ; Thu, 3 Aug 2006 06:18:21 -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 14793-10 for ; Thu, 3 Aug 2006 09:18:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from rrzmta2.rz.uni-regensburg.de (rrzmta2.rz.uni-regensburg.de [132.199.1.17]) by postgresql.org (Postfix) with ESMTP id 0EE4D9FB285 for ; Thu, 3 Aug 2006 06:18:01 -0300 (ADT) Received: from rrzmta2.rz.uni-regensburg.de (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id 1BBA445B23 for ; Thu, 3 Aug 2006 11:18:03 +0200 (CEST) Received: from rrzgw1.uni-regensburg.de (rrzgw1.rz.uni-regensburg.de [132.199.4.10]) by rrzmta2.rz.uni-regensburg.de (Postfix) with ESMTP id 0D0E245B1C for ; Thu, 3 Aug 2006 11:18:03 +0200 (CEST) Received: from uni-regensburg-MTA by rrzgw1.uni-regensburg.de with Novell_GroupWise; Thu, 03 Aug 2006 11:17:58 +0200 Message-Id: <44D1DB56.0AD0.0080.0@klinik.uni-regensburg.de> X-Mailer: Novell GroupWise Internet Agent 7.0.1 Date: Thu, 03 Aug 2006 11:17:43 +0200 From: "Christian Rengstl" To: "Richard Huxton" , "Hakan Kocaman" Cc: Subject: Re: Query performance References: <84AAD313D71B1D4F9EE20E739CC3B6ED0116180C@ATLANTIK-CL.intern.digame.de> In-Reply-To: <84AAD313D71B1D4F9EE20E739CC3B6ED0116180C@ATLANTIK-CL.intern.digame.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.816 tagged_above=0 required=5 tests=SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: *** X-Archive-Number: 200608/153 X-Sequence-Number: 98925 Hi, i would rather compare int4 too, but the snp_id can be something like = "abc123" unfortunately. "Hakan Kocaman" wrote on 08/03/06 11:08 am: > Hi, >=20 >=20 >> -----Original Message----- >> From: Richard Huxton [mailto:dev@archonet.com]=20 >> Sent: Thursday, August 03, 2006 11:00 AM >> To: Christian Rengstl >> Cc: Hakan Kocaman; pgsql-general@postgresql.org=20 >> Subject: Re: [GENERAL] Query performance >>=20 >>=20 >> Christian Rengstl wrote: >> > Hi, >> >=20 >> > the complete query is the one i posted, but here comes the=20 >> schema for mytable: >> > entry_no int8 NOT NULL DEFAULT nextval('entry_no_seq''::regclass), >> > pid varchar(15) NOT NULL,=20 >> > crit varchar(13) NOT NULL, >> > val1 varchar(1), >> > val2 varchar(1), >> > aendat text, >> > aennam varchar(8), >> > CONSTRAINT "PK_ENTRY" PRIMARY KEY (entry_no) >> >=20 >> > myCritTable: >> > crit varchar(13) NOT NULL, >> > chr int2, >> > aendat timestamp, >> > CONSTRAINT pk_crit_master PRIMARY KEY (crit) >>=20 >> Still doesn't match the EXPLAIN output - where's snp_id?=20 >> Where's table=20 >> test2? >>=20 >=20 > Yep, that bothered me too. >=20 >> > My server is 8.1.4. As a matter of fact, i have no idea=20 >> where the text=20 >> > type comes from, because as you can see from above there are only >> > varchar with maximum 15 characters. >>=20 >> PG is casting it to text. There's no real difference between=20 >> the types=20 >> (other than the size limit) and it's not expensive. >=20 > But wouldn't a comparison between int4 be much cheaper. > If i see smth like "id" (here snp_id) in a fieldname it should be a=20 > int-type, i think. >=20 >>=20 >> > "Hakan Kocaman" wrote on 08/03/06=20 >> 10:34 am: >> >> Hi, >> >> >> >> can you post the complete query,schema- and=20 >> >> 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 =3D ("inner".snp_id)::text) >> >> -> Bitmap Heap Scan on test2 (cost=3D232.92..132766.66=20 >> rows=3D37120=20 >> >> width=3D23)=20 >> >> (actual time=3D291.600..356707.737 rows=3D37539 loops=3D1) >> >> This part is very expensive, but i got no clue why. >>=20 >> Yep, it looks like the "Bitmap Heap Scan" is at the heart of=20 >> this. You=20 >> might want to increase work_mem, it could be that the bitmap=20 >> is spilling=20 >> to disk (which is much slower than keeping it all in RAM) >>=20 >> http://www.postgresql.org/docs/8.1/static/runtime-config-resou=20 > rce.html#RUNTIME-CONFIG-RESOURCE-MEMORY >=20 > If it's still at 1MB (1024), try 5MB, 10MB, 50MB and see what happens. >=20 > --=20 > Richard Huxton > Archonet Ltd >=20 >=20 >=20 > Hakan Kocaman > Software-Development >=20 > digame.de GmbH > Richard-Byrd-Str. 4-8 > 50829 K=F6ln >=20 > Tel.: +49 (0) 221 59 68 88 31 > Fax: +49 (0) 221 59 68 88 98 > Email: hakan.kocaman@digame.de=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match -- Christian Rengstl M.A. Klinik und Poliklinik f=FCr Innere Medizin II Kardiologie - Forschung Universit=E4tsklinikum Regensburg B3 1.388 Franz-Josef-Strauss-Allee 11 93053 Regensburg Tel.: +49-941-944-7230