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 2CFBA32AABA for ; Fri, 8 Oct 2004 18:28:36 +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 94752-10 for ; Fri, 8 Oct 2004 17:27:54 +0000 (GMT) Received: from mail.deg.cc (unknown [64.139.134.201]) by svr1.postgresql.org (Postfix) with ESMTP id A2EAA329E64 for ; Fri, 8 Oct 2004 18:27:54 +0100 (BST) Received: from deg.cc (unknown [198.70.16.205]) by mail.deg.cc (Postfix) with ESMTP id 711FB560C1; Fri, 8 Oct 2004 13:27:49 -0400 (EDT) Message-ID: <4166CE72.2050900@deg.cc> Date: Fri, 08 Oct 2004 13:29:22 -0400 From: Pallav Kalva User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040308 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-performance@postgresql.org Subject: Re: Query Tuning References: <4166A8E8.4060102@deg.cc> <13657.1097253776@sss.pgh.pa.us> In-Reply-To: <13657.1097253776@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/106 X-Sequence-Number: 8582 Tom Lane wrote: >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 > > > Thanks! for the quick reply. I cant run the EXPLAIN ANALYZE on the live database because, it takes lot of time and hols up lot of other queries on the table. The postgres version I am using is 7.4 . when you say " i never vacuum/analyxed the copy" you mean the Live database ? or the copy of the live database ? . I run vacuum database daily on my live database as a part of daily maintanence.