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-21 06:43:08 |
Message-ID: | 1350801788.27983.13.camel@jdavis |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Sun, 2012-10-21 at 08:37 +1300, Jeremy Wells wrote:
> Jeff Davis wrote:
> > Can you post the output of EXPLAIN ANALYZE? Did you do an ANALYZE of the
> > tables already?
> EXPLAIN ANALYZE SELECT COUNT(*) FROM "invites" INNER JOIN
> "sms_requests" ON "sms_requests"."invoker_id" = "invites"."id" AND
> "sms_requests"."invoker_type" = 'Invite' INNER JOIN "sms_messages" ON
> "sms_messages"."id" = "sms_requests"."sms_message_id" WHERE
> "sms_messages"."sent_at" IS NOT NULL;
>
Interesting... it looks like the two plans take about the same amount of
time, so the planner is not making a mistake.
I tried making three tables about the same size as yours, and then doing
a three-way join, and on my machine it took closer to a second. So
there's clearly something else going on with your data. Maybe the data
distribution is skewed (some values having many matches in another
table, others having none)?
Regards,
Jeff Davis
From | Date | Subject | |
---|---|---|---|
Next Message | Jeremy Wells | 2012-10-21 08:49:12 | Re: indexes across joins not used for count |
Previous Message | Jeremy Wells | 2012-10-20 19:37:51 | Re: indexes across joins not used for count |