Search Postgresql Archives

Re: How to use index in WHERE int = float

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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

Only way to fix this it to replace parameters manually by creating strings which I'm trying to do for slow queries.

I have a feeling you've given us a
simplified example of your problem.  It might help to see the real
problem.

I has feeling that PostgreSql must determine that index is integer type and convert float to integer itself to speed it up.

Another issue:

Wuery

  SELECT dokumnr
    FROM DOK
   where dokumnr IN (123)
AND ( '0' or
 dokumnr IN (SELECT dokumnr FROM bilkaib WHERE
        alusdok='LG' AND masin LIKE 'a%') )

runs slowly.

If

'0' or

is removed form where clause it runs fast since it founds indexes.

It is real surpise that expression containing

'0' or

prevents PostgreSql to use indexes.


I have changed those queries to manually created better sql statements which run fast.
however I expected that PsotgreSql can optimize those itself.

Andrus.

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux