Re: Sequencial scan in a JOIN

From: Shaun Thomas <sthomas(at)optionshouse(dot)com>
To: Andrew Jaimes <andrewjaimes(at)hotmail(dot)com>
Cc: Postgres Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Sequencial scan in a JOIN
Date: 2012-06-05 14:02:08
Message-ID: 4FCE1160.4070003@optionshouse.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 06/05/2012 08:31 AM, Andrew Jaimes wrote:

> the default_statistics_target is set to 200, and I have run the analyze
> and reindex on these tables before writing the email.

Out of idle curiosity, how do these two variants treat you?

SELECT count(1)
FROM e_usersessions s
JOIN l_userqueue q ON (q.userid = s.entityid)
JOIN a_activity a ON (a.activequeueid = q.queueid)
WHERE s.sessionkeepalivedatetime > 20120605082131943
AND a.vstatus = 1
AND a.ventrydate > 0
AND a.sbuid = s.sbuid
AND a.assignedtoid = 0
AND a.status <> '0'

SELECT count(1)
FROM e_usersessions s
JOIN l_userqueue q ON (q.userid = s.entityid)
WHERE s.sessionkeepalivedatetime > 20120605082131943
AND EXISTS (
SELECT 1 FROM a_activity a
WHERE a.activequeueid = q.queueid
AND a.sbuid = s.sbuid
AND a.vstatus = 1
AND a.ventrydate > 0
AND a.assignedtoid = 0
AND a.status <> '0'
)

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

______________________________________________

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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Shaun Thomas 2012-06-05 14:57:14 Re: Sequencial scan in a JOIN
Previous Message Andrew Jaimes 2012-06-05 13:31:19 Re: Sequencial scan in a JOIN