Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 525DB98F705 for ; Tue, 5 Jun 2012 10:16:01 -0300 (ADT) Received: from smtp2.peak6.com ([38.98.137.9]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sbtc7-00034f-AO for pgsql-performance@postgresql.org; Tue, 05 Jun 2012 13:16:00 +0000 X-AuditID: 0a02cb1e-b7fa76d000000a63-87-4fce066f052d Message-ID: <4FCE0681.5040306@optionshouse.com> Date: Tue, 5 Jun 2012 08:15:45 -0500 From: Shaun Thomas Reply-To: Organization: Peak6 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Andrew Jaimes CC: Subject: Re: Sequencial scan in a JOIN References: In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1"; format=flowed content-transfer-encoding: 7bit X-Originating-IP: [10.10.201.64] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLIsWRmVeSWpSXmKPExsXClcIrppvPds7fYMolQYvV/y6xWlyfeY7Z gcnjcc8ZNo8L+6axBzBFNTDaJObl5ZcklqQqpKQWJ9sq+ReUZObnFXvklxanKrhkFifnJGbm phYpKWSm2CqZKykU5CQmp+am5pXYKiUWFKTmpSjZcSlgABugssw8hdS85PyUzLx0WyXPYH9d CwtTS11DJbt4ZJDQyZIxYclX1oKN7BVdE/IbGL+xdjFyckgImEis2fOcBcIWk7hwbz1bFyMH B6+AvsSJ2WwgYRYBFYmGvU8ZQWw2AV2JSf0rwOJCQPG+szeYQGx+AWGJfR+amEFsUYEQiXNP voPV8AoISpyc+QRsvIiAjsSGpa/B1jILqEnMfTgJzBYWMJDo6drLDDHTUmLHomNgcU4BK4kN d25A1dtKXJhznQXClpfY/nYOVL2qxIrmiWwQ5ytI/L/yjmkCo9AsJKtnIWmfhaR9ASPzKkbx 4rLE5IxMs4Li3JICQ72C1MRsM7281JJNjKCoZTott4NxxQXFQ4wCHIxKPLwFZ8/4C7EmlhVX 5h5ilOBgVhLhzQo/6y/Em5JYWZValB9fVJqTWnyI0RQYZhOZpUST84EJJa8k3tDY0NLU0sTM 0tzY2EBJnPf7WqA5AunAxJCdmlqQWgTTx8TBKdXAuMWJ/9bCloLfgorNn+98aInvjH3Z6fDM NVHb2WqTQfz2LbPjvsorpUQEais5rd110OK0QeoWxScmR6tKNtqKznYT+ftXUy93yeuP3WVq XOxhzzZ8Mrk0M11vsZsLe6AIT8tRR++w47/PdTx8yNH/63zSs9ZtbC2Lfj9WmbLzpNKNmhV/ Uw44K7EUZyQaajEXFScCALjQ+ybwAgAA X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/20 X-Sequence-Number: 47046 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