Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 96E5B9FB631 for ; Wed, 9 May 2007 10:29:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 07157-01 for ; Wed, 9 May 2007 10:29:24 -0300 (ADT) X-Greylist: delayed 00:06:40.97625 by SQLgrey-1.7.5 Received: from mx1.wp.pl (mx1.wp.pl [212.77.101.5]) by postgresql.org (Postfix) with ESMTP id 83AA99FB599 for ; Wed, 9 May 2007 10:29:24 -0300 (ADT) Received: (wp-smtpd smtp.wp.pl 21391 invoked from network); 9 May 2007 15:22:41 +0200 Received: from bramka-zew.dfqs.pl (HELO [192.168.2.69]) (zawadaa@[194.126.222.22]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with AES256-SHA encrypted SMTP for ; 9 May 2007 15:22:41 +0200 Message-ID: <4641CB21.2010608@wp.pl> Date: Wed, 09 May 2007 15:22:41 +0200 From: Andrzej Zawadzki User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.2) Gecko/20070321 PLD/2.0 (Ac) SeaMonkey/1.1.1 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Poor performance with queries using clause: sth IN (...) Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit X-WP-AV: skaner antywirusowy poczty Wirtualnej Polski S. A. X-WP-SPAM: NO 0000000 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200705/184 X-Sequence-Number: 24574 That's email from my friend. Any hint? -------- Original Message -------- Subject: bug Date: Wed, 09 May 2007 15:03:00 +0200 From: Michal Postupalski To: Andrzej Zawadzki We've just changed our database from 8.1 to 8.2 and we are grief-stricken about very poor performance with queries using clause: "sth IN (...)". As we can see any query is translate to "sth = ANY ('{....}'::bpchar[]))" and it tooks much more time beacuse it doesn't use index'es. Why ? How can we speed up these queries? I've just read "Performance of IN (...) vs. = ANY array[...]" on pgsql-performance mailing list and I didn't find any solutions. Can anybody tell me what can I do with postgres to force him using indexes? If there isn't any solution I'm afraid that we will have to do downgrade to previous version 8.1. example: SELECT count(*) FROM kredytob b, kredyty k WHERE true AND b.kredytid = k.id AND '' IN ('', upper(b.nazwisko)) AND '' IN ('', upper(b.imie)) AND '78111104485' IN ('', b.pesel) AND '' IN ('', upper(trim(b.dowseria))) AND '' IN ('', b.dowosnr) AND 0 IN (0, b.typkred) AND k.datazwrot IS NULL; regards... Micha³ Postupalski