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 5908832A704 for ; Fri, 8 Oct 2004 17:43:11 +0100 (BST) 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 82826-04 for ; Fri, 8 Oct 2004 16:42:59 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 327F132A6A5 for ; Fri, 8 Oct 2004 17:42:59 +0100 (BST) 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 i98GguGn013658; Fri, 8 Oct 2004 12:42:57 -0400 (EDT) To: Pallav Kalva Cc: pgsql-performance@postgresql.org Subject: Re: Query Tuning In-reply-to: <4166A8E8.4060102@deg.cc> References: <4166A8E8.4060102@deg.cc> Comments: In-reply-to Pallav Kalva message dated "Fri, 08 Oct 2004 10:49:12 -0400" Date: Fri, 08 Oct 2004 12:42:56 -0400 Message-ID: <13657.1097253776@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM X-Spam-Level: * X-Archive-Number: 200410/105 X-Sequence-Number: 8581 Pallav Kalva writes: > I have a problem with the below query, when i do explain on the > below query on my live database it doesnt use any index specified on the > tables and does seq scan on the table which is 400k records. But if i > copy the same table onto a different database on a different machine it > uses all the indexes specified and query runs much quicker. It looks to me like you've never vacuumed/analyzed the copy, and so you get a different plan there. The fact that that plan is better than the one made with statistics is unhappy making :-( ... but when you only show us EXPLAIN output rather than EXPLAIN ANALYZE, it's impossible to speculate about why. Also, what PG version is this? regards, tom lane