pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shaun Thomas <sthomas@optionshouse.com>
To: Andrew Jaimes <andrewjaimes@hotmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Sequencial scan in a JOIN
Date: Tue, 5 Jun 2012 08:15:45 -0500
Message-ID: <4FCE0681.5040306@optionshouse.com> (raw)
In-Reply-To: <BLU161-W1125BE7D5AED110518DEFFDD0C0@phx.gbl>
References: <BLU161-W1125BE7D5AED110518DEFFDD0C0@phx.gbl>

On 06/05/2012 07:48 AM, Andrew Jaimes wrote:

> '  ->  Hash Join  (cost=10.93..99795.09 rows=242803 width=0) (actual
> time=0.541..2249.027 rows=33 loops=1)'
> '        Hash Cond: ((a_activity.activequeueid = l_userqueue.queueid)
> AND (a_activity.sbuid = e_usersessions.sbuid))'
> '        ->  Seq Scan on a_activity  (cost=0.00..88462.52 rows=1208167
> width=22) (actual time=0.010..1662.142

I'd be willing to bet your stats are way, way off. It expected 242,803 
rows in the hash, but only got 33. In that kind of scenario, I could 
easily see the planner choosing a sequence scan over an index scan, as 
doing that many index seeks would be much more expensive than scanning 
the table.

What's your default_statistics_target, and when is the last time you 
analyzed the tables in this query?

-- 
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604
312-444-8534
sthomas@optionshouse.com

______________________________________________

See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email



view thread (6+ messages)  latest in thread

Message-ID: <4FCE0681.5040306@optionshouse.com>
Permalink:  ../4FCE0681.5040306@optionshouse.com/
Also on:    postgresql.org/message-id/4FCE0681.5040306@optionshouse.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: sthomas@optionshouse.com, andrewjaimes@hotmail.com
  Subject: Re: Sequencial scan in a JOIN
  In-Reply-To: <4FCE0681.5040306@optionshouse.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