Re: Sequencial scan in a JOIN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx

______________________________________________

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

--
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux