Re: How to use index in WHERE int = float

Поиск
Список
Период
Сортировка
От Andrus
Тема Re: How to use index in WHERE int = float
Дата
Msg-id 6C07D560D6F34095AF2DD2694552B76D@andrusnotebook
обсуждение исходный текст
Ответ на Re: How to use index in WHERE int = float  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Ответы Re: How to use index in WHERE int = float  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Re: How to use index in WHERE int = float  (Sam Mason <sam@samason.me.uk>)
Список pgsql-general
> 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.


В списке pgsql-general по дате отправления:

Предыдущее
От: "Andrus"
Дата:
Сообщение: Speeding up startswith query
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: How to use index in WHERE int = float