X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id CDD35475458 for ; Wed, 30 Apr 2003 11:14:23 -0400 (EDT) Received: from mail.speakeasy.net (mail15.speakeasy.net [216.254.0.215]) by postgresql.org (Postfix) with ESMTP id 7F876475458 for ; Wed, 30 Apr 2003 11:13:52 -0400 (EDT) Received: (qmail 22362 invoked from network); 30 Apr 2003 15:09:16 -0000 Received: from unknown (HELO pdarley) (kinesis@[216.254.16.50]) (envelope-sender ) by mail15.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 30 Apr 2003 15:09:16 -0000 From: "Peter Darley" To: "Tom Lane" Cc: Subject: Re: Query Plan far worse in 7.3.2 than 7.2.1 Date: Wed, 30 Apr 2003 08:09:12 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal In-Reply-To: <22179.1051714467@sss.pgh.pa.us> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Status: No, hits=-37.2 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,MSGID_GOOD_EXCHANGE, ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/262 X-Sequence-Number: 1768 Tom, You hit the nail on the head, foreign_key is a varchar(250). I'll re-write the queries with explicit casts. I'm hesitant to say anything, because I'm really not in a position to contribute, but... It seems like there are getting to be lots of typing issues (this one, 2 isn't an int8, etc.) I think that people have said that things are like this to support user defined data types. I would happily get rid of user defined data types if it would help with the type conversion issues. Just my 2c, for what it's worth. Thanks, Peter Darley -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us] Sent: Wednesday, April 30, 2003 7:54 AM To: Peter Darley Cc: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Query Plan far worse in 7.3.2 than 7.2.1 "Peter Darley" writes: > SELECT COUNT(*) FROM Border_Shop_List WHERE NOT EXISTS (SELECT Foreign_Key= > FROM Sample WHERE Foreign_Key=3D'Quantum_' || Border_Shop_List.Assignment_= > ID || '_' || Assignment_Year || '_' || Evaluation_ID) What's the datatype of Foreign_Key? I'm betting that it's varchar(n) or char(n). The result of the || expression is text, and so the comparison can't use a varchar index unless you explicitly cast it to varchar: WHERE Foreign_Key = ('Quantum_' || ... || Evaluation_ID)::varchar I think 7.2 had some kluge in it that would allow a varchar index to be used anyway, but we took out the kluge because it was semantically wrong (it would also allow use of a char(n) index in place of a text comparison, which alters the semantics...) regards, tom lane