Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 899B614FDE0B for ; Mon, 7 Nov 2011 18:52:09 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 64957-06 for ; Mon, 7 Nov 2011 22:52:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id 34F2F14FDE0A for ; Mon, 7 Nov 2011 18:52:03 -0400 (AST) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Mon, 07 Nov 2011 16:52:02 -0600 Message-Id: <4EB80CAA0200002500042B3B@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Mon, 07 Nov 2011 16:51:54 -0600 From: "Kevin Grittner" To: "Jay Levitt" Cc: Subject: Re: Subquery in a JOIN not getting restricted? References: <4EB84CB4.2010102@gmail.com> <4EB7FEFD0200002500042B1C@gw.wicourts.gov> In-Reply-To: <4EB7FEFD0200002500042B1C@gw.wicourts.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-3.101 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.201 X-Spam-Level: X-Archive-Number: 201111/103 X-Sequence-Number: 45614 "Kevin Grittner" wrote: > If I had made the scores table wider, it might have gone from the > user table to scores on the index. Bah. I just forgot to put an index on scores.user_id. With that index available it did what you were probably expecting -- seq scan on questions, nested loop index scan on users, nested loop index scan on scores. You weren't running you test with just a few rows in each table and expecting the same plan to be generated as for tables with a lot of rows, were you? -Kevin