From: | Sam Mason <sam(at)samason(dot)me(dot)uk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to use index in WHERE int = float |
Date: | 2008-11-05 19:16:54 |
Message-ID: | 20081105191654.GU2459@frubble.xen.chris-lamb.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, Nov 05, 2008 at 08:52:50PM +0200, Andrus wrote:
> explain analyze select * from firma2.dok where dokumnr='1228137'::float8
>
> "Seq Scan on dok (cost=0.00..187766.23 rows=6255 width=1145) (actual
> time=43168.460..43176.063 rows=1 loops=1)"
> " Filter: ((dokumnr)::double precision = 1228137::double precision)"
> "Total runtime: 43176.375 ms"
>
> shows that index is not used and thus query takes very long time.
>
> How to force PostgreSql to speed up without changing query ?
I'm not sure if PG 8.1 will recognize it, but you could try creating a
functional index on the column when cast to the appropriate type. I.e:
CREATE INDEX dok_dokumnr_float8_idx ON dok (((dokumnr)::double precision));
Sam
From | Date | Subject | |
---|---|---|---|
Next Message | CG | 2008-11-05 19:29:29 | Best way to debug user defined type |
Previous Message | Sam Mason | 2008-11-05 19:11:41 | Re: Speeding up query |