Re: How to use index in WHERE int = float - Mailing list pgsql-general

From Scott Marlowe
Subject Re: How to use index in WHERE int = float
Date
Msg-id dcc563d10811051348s1320409cw1bbc712fc4107545@mail.gmail.com
Whole thread Raw
In response to Re: How to use index in WHERE int = float  ("Andrus" <kobruleht2@hot.ee>)
Responses Re: How to use index in WHERE int = float  ("Andrus" <kobruleht2@hot.ee>)
List pgsql-general
On Wed, Nov 5, 2008 at 2:42 PM, Andrus <kobruleht2@hot.ee> wrote:
>> Stop trying to compare exact and inexact types?
>>
>> You do realize that a float is not an exact number.  What you and I
>> see as 1228137 might really be, internally, 1228136.9999999999999999 ?
>> So it won't get an exact match.  What's wrong with trying to match to
>> an exact number instead?
>
> My query contains
>
> '1228137'::float8
>
> I do'nt see
>
> 1228136.9999999999999999
>
> in this query.

Did you read what I wrote?  Cause you just repeated it as an argument
against my point.

 I don't think you get the difference between exact and inexact types.
 Google it for more comprehensive reading on the subject.

> Those strange casts are auto-generated by ODBC parameter passing software
> which I must use so I must live with it.

Sorry to hear that.

PostgreSQL doesn't automatically use indexes when comparing
incompatible types (i.e. exact versus non-exact types) so it's up to
you to use casting to make them match up.  There are lots of things
you can do here, but if you're comparing ints with floats you will
eventually be bitten by some comparison that should match but doesn't.
 Stick to exact number types if possible.

pgsql-general by date:

Previous
From: "Andrus"
Date:
Subject: Re: How to use index in WHERE int = float
Next
From: Sam Mason
Date:
Subject: Re: How to use index in WHERE int = float