Folks,
I have som large data basees (from 7 million to 20 million
records and growing) and want to optimize selection in a
range between two float4 values. I have made indices on the
relevant variables.
I notice that a query such as:
select count(*) from mydata where x='3.4';
executes in under 10 seconds. However, a query such as
select count(*) from mydata where x>'3.4' and x<'3.5';
takes at least 20 minutes. EXPLAIN suggests that both
are using an index scan.
Not forcing float4 conversion does much better, e.g.
select count(*) from mydata where x>3.4 and x<3.5;
returns in under a minute although EXPLAIN suggests
that an sequential scan is used.
Can anyone give me some guidance on what that best
strategy is do select records in a range of float4
values?
Thanks!
--Martin
P.S. This behavior is also present in 6.4.2.
===========================================================================
Martin Weinberg Phone: (413) 545-3821
Dept. of Physics and Astronomy FAX: (413) 545-2117/0648
530 Graduate Research Tower
University of Massachusetts
Amherst, MA 01003-4525