Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 4CA6EB5F4DB for ; Tue, 4 Oct 2011 10:27:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 15088-02 for ; Tue, 4 Oct 2011 13:27:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from depesz.com (andy.depesz.com [88.198.47.100]) by mail.postgresql.org (Postfix) with ESMTP id 876FDB5DF16 for ; Tue, 4 Oct 2011 09:55:38 -0300 (ADT) Received: from andy.depesz.com ([88.198.47.100] helo=depesz.com) by depesz.com with esmtpa (Exim 4.76) (envelope-from ) id 1RB4X3-0006OG-3X; Tue, 04 Oct 2011 14:55:37 +0200 Date: Tue, 4 Oct 2011 14:55:36 +0200 From: hubert depesz lubaczewski To: "Soporte @ TEKSOL S.A." Cc: pgsql-performance@postgresql.org Subject: Re: pkey is not used on productive database Message-ID: <20111004125536.GA21733@depesz.com> Reply-To: depesz@depesz.com References: <014c01cc81f4$a774e140$f65ea3c0$@teksol.com.ar> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <014c01cc81f4$a774e140$f65ea3c0$@teksol.com.ar> User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/40 X-Sequence-Number: 45262 On Mon, Oct 03, 2011 at 02:48:10PM -0300, Soporte @ TEKSOL S.A. wrote: > Hi, > > > > I need help to understand the issue on a productive database for a select > that takes more time than expected. > > > > 1- On a development database I ran the query (select) and I can see on > Explain Analyze pgAdmin use all the indexes and primary keys defined. Dev db > has almost 10% of productive data. > > 2- On productive database the same query on Explain Analyze from > pgAdmin shows a diferent planning, not using a pkey index and instead uses > the progressive scan on a million of rows. I can see Primary key is defined > for the table on pgAdmin. > > > > What could be the issue on a productive for not use the pkey index for the > SELECT? general answer: http://www.depesz.com/index.php/2010/09/09/why-is-my-index-not-being-used/ but for more details, we'd need to see the query and \d of the table. Best regards, depesz -- The best thing about modern society is how easy it is to avoid contact with it. http://depesz.com/