Re: indexes across joins not used for count

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Jeremy Wells <jemmyw(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: indexes across joins not used for count
Date: 2012-10-20 18:21:22
Message-ID: 1350757282.14401.11.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Tue, 2012-10-16 at 16:08 +1300, Jeremy Wells wrote:
> I'm running a query to do a count with two joins in it. I've added
> indexes to the tables for the join columns, but the explain of the query
> doesn't seem to be using the indexes:

Can you post the output of EXPLAIN ANALYZE? Did you do an ANALYZE of the
tables already?

You can often force an index scan by doing:

SET enable_seqscan=false;

So also try setting that, and run EXPLAIN ANALYZE again, and see if it
uses the indexes, and if so, if it's faster.

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jeremy Wells 2012-10-20 19:37:51 Re: indexes across joins not used for count
Previous Message Jeff Davis 2012-10-20 17:40:59 Re: Guidance needed to be a postgreSQL DBA