pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim C. Nasby <jnasby@pervasive.com>
To: Greg Stark <gsstark@mit.edu>
Cc: Alex Adriaanse <alex@innovacomputing.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Bad row estimates
Date: Sat, 4 Mar 2006 09:46:05 -0600
Message-ID: <20060304154605.GC80721@pervasive.com> (raw)
In-Reply-To: <87wtfasng0.fsf@stark.xeocode.com>
References: <4408E91C.90104@innovacomputing.com>
	<87wtfasng0.fsf@stark.xeocode.com>

On Sat, Mar 04, 2006 at 02:01:35AM -0500, Greg Stark wrote:
> Alex Adriaanse <alex@innovacomputing.com> 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@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461



view thread (8+ messages)  latest in thread

Message-ID: <20060304154605.GC80721@pervasive.com>
Permalink:  ../20060304154605.GC80721@pervasive.com/
Also on:    postgresql.org/message-id/20060304154605.GC80721@pervasive.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jnasby@pervasive.com, gsstark@mit.edu, alex@innovacomputing.com
  Subject: Re: Bad row estimates
  In-Reply-To: <20060304154605.GC80721@pervasive.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox