From: Josh Berkus <josh@agliodbs.com>
To: Laszlo Nagy <gandalf@shopzeus.com>
Cc: pgsql-performance@postgresql.org, Daniel Fekete <danieleff@gmail.com>
Subject: Re: Bad query plan when the wrong data type is used
Date: Tue, 08 Feb 2011 14:04:59 -0800
Message-ID: <4D51BE0B.1060404@agliodbs.com> (raw)
In-Reply-To: <4D514FFF.9060308@shopzeus.com>
References: <4D514FFF.9060308@shopzeus.com>
Laszlo,
> Which is silly. I think that PostgreSQL converts the int side to a
> float, and then compares them.
>
> It would be better to do this, for each item in the loop:
>
> * evaluate the right side (which is float)
> * tell if it is an integer or not
> * if not an integer, then discard the row immediately
> * otherwise use its integer value for the index scan
Not terribly likely, I'm afraid. Data type coercion is *way* more
complex than you realize (consider the number of data types we have, and
the ability to add UDTs, and then square it). And the functionality you
propose would break backwards compatibility; many people currently use
".0" currently in order to force a coercion to Float or Numeric.
I'm not saying that PostgreSQL couldn't do better on this kind of case,
but that doing better is a major project, not a minor one.
--
-- Josh Berkus
PostgreSQL Experts Inc.
http://www.pgexperts.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: josh@agliodbs.com, gandalf@shopzeus.com, danieleff@gmail.com
Subject: Re: Bad query plan when the wrong data type is used
In-Reply-To: <4D51BE0B.1060404@agliodbs.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox