Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D4365650EA1 for ; Thu, 26 Jun 2008 04:03:16 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 08474-07 for ; Thu, 26 Jun 2008 04:02:55 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.28]) by postgresql.org (Postfix) with ESMTP id 9186D650E83 for ; Thu, 26 Jun 2008 04:02:13 -0300 (ADT) Received: by yw-out-2324.google.com with SMTP id 3so1098429ywj.73 for ; Thu, 26 Jun 2008 00:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=wjVAFwryXVPscLNChKT6Z/pC6ut9MBaZ8XM0RY1LYG0=; b=WMXLxqiKi9Y6C4tpaPzZcdsVDVJUpNxz1joBVgGBp27IWUPT7LU9JDEU90mpPay0D8 CMRyZicw+rE1bn18mOW2pcrhdQOA1cRq1wk+gTUNvM3yp6cxMj84CqyA7Hg2Mtono+qm StpGL9Hzz1nNdV6To9BGBrZoqjZPRUdNnJAJU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=tWPIcQ0/JOeDkLOVn3tEYTAWYy1qZkM3clkBIYkcEB3Xws0hz9RkpRrJQry5LGjnwW mOWFlBxQADdB10V7TnS4voRu2hT3LW07COUh/punKsIZ9ZDjdVga9TWK/Xzk6jCwxJQc bbImriaaa+PRyrozPwzXf4JcR7intQQPxP06U= Received: by 10.151.112.4 with SMTP id p4mr1294401ybm.167.1214463733132; Thu, 26 Jun 2008 00:02:13 -0700 (PDT) Received: by 10.150.217.9 with HTTP; Thu, 26 Jun 2008 00:02:13 -0700 (PDT) Message-ID: <7d10d2df0806260002w8707ea1rf8f62ca8126099a8@mail.gmail.com> Date: Thu, 26 Jun 2008 08:02:13 +0100 From: "Frank Joerdens" To: "Craig James" Subject: Re: Typecast bug? Cc: pgsql-performance@postgresql.org In-Reply-To: <4863186E.1000306@emolecules.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <47FFA7FF.10801@postnewspapers.com.au> <544D07A2-EB3F-4D91-A749-0C4D5D38AB80@gmail.com> <481F992D.7070509@emolecules.com> <4820A3C2.4000307@emolecules.com> <4820C30A.8010709@emolecules.com> <4863186E.1000306@emolecules.com> X-Google-Sender-Auth: 186785bc49e48670 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200806/159 X-Sequence-Number: 30509 On 6/26/08, Craig James wrote: > This seems like a bug to me, but it shows up as a performance problem. > Since the column being queried is an integer, the second query (see below) > can't possibly match, yet Postgres uses a typecast, forcing a full table > scan for a value that can't possibly be in the table. Which version are you using? 8.3 removes a lot of implicit casts (all? not sure), so this may already be your fix. Cheers, Frank