Re: Bad row estimates

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

 



On Sat, Mar 04, 2006 at 02:01:35AM -0500, Greg Stark wrote:
> Alex Adriaanse <alex@xxxxxxxxxxxxxxxxxxx> writes:
> 
> > SELECT count(*) FROM test_table_1
> >     INNER JOIN test_table_2 ON
> >         (test_table_2.s_id = 13300613 AND test_table_1.id = test_table_2.n_id)
> >     WHERE now() BETWEEN test_table_1.start_ts AND test_table_1.end_ts
> >     AND test_table_1.id = test_table_1.g_id;

Something else that helps in cases like this is to place both an upper
and lower boundary on one (or both) fields if possible. For example, if
you know that start_ts and end_ts will always be within 1 hour of each
other, adding the following will help:

AND start_ts >= now()-'1 hour'::interval AND end_ts <= now()+'1
hour'::interval
-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby@xxxxxxxxxxxxx
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux