X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 885C152BC3 for ; Mon, 1 Aug 2005 21:15:31 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12235-05 for ; Tue, 2 Aug 2005 00:15:26 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id AB6F4529E1 for ; Mon, 1 Aug 2005 21:15:25 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j720FQaO026293; Mon, 1 Aug 2005 20:15:26 -0400 (EDT) To: meetesh.karia@alumni.duke.edu Cc: John Arbash Meinel , pgsql-performance@postgresql.org Subject: Re: Planner incorrectly choosing seq scan over index scan In-reply-to: References: <42EEAD4B.4010905@arbash-meinel.com> Comments: In-reply-to Meetesh Karia message dated "Tue, 02 Aug 2005 01:56:13 +0200" Date: Mon, 01 Aug 2005 20:15:26 -0400 Message-ID: <26292.1122941726@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200508/17 X-Sequence-Number: 13764 Meetesh Karia writes: > Sure. The lte_user table is just a collection of users. user_id is assigned= > uniquely using a sequence. During some processing, we create a candidates= > table (candidates617004 in our case). This table is usually a temp table.= > sourceid is a user_id (in this case it is always 617004) and targetid is=20 > also a user_id (2860 distinct values out of 3467). The rest of the=20 > information is either only used in the select clause or not used at all=20 > during this processing. If you know that sourceid has only a single value, it'd probably be helpful to call out that value in the query, ie, where ... AND c.sourceId = 617004 ... regards, tom lane