Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 9532FB5DBC2 for ; Thu, 16 Jun 2011 14:03:18 -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 66672-10 for ; Thu, 16 Jun 2011 17:03:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from shrek.krogh.cc (2605ds1-ynoe.0.fullrate.dk [90.184.12.24]) by mail.postgresql.org (Postfix) with ESMTP id E3373B5D8BD for ; Thu, 16 Jun 2011 14:03:11 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by shrek.krogh.cc (Postfix) with ESMTP id F05BD339028 for ; Thu, 16 Jun 2011 19:03:09 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at shrek.krogh.cc Received: from shrek.krogh.cc ([127.0.0.1]) by localhost (shrek.krogh.cc [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FS-0RGb8pYYm for ; Thu, 16 Jun 2011 19:03:07 +0200 (CEST) Received: from [90.184.13.151] (2605ds1-ynoe.2.fullrate.dk [90.184.13.151]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: jesper@krogh.cc) by shrek.krogh.cc (Postfix) with ESMTPSA id 0EE2F338FF5 for ; Thu, 16 Jun 2011 19:03:07 +0200 (CEST) Message-ID: <4DFA3749.3000306@krogh.cc> Date: Thu, 16 Jun 2011 19:03:05 +0200 From: Jesper Krogh User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: seq scan in the case of max() on the primary key column References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201106/139 X-Sequence-Number: 44072 On 2011-06-16 15:55, Svetlin Manavski wrote: > Hi everybody, > > I am running PostgreSQL 9.0 which performs well in most of the cases. I > would skip all the parameters if these are not necessary. > > I need to frequently (every min) get the max value of the primary key column > on some tables, like this case which works perfectly well: > > explain analyze select max(id) from appqosdata.tcpsessions; Typically this is due to "batch load" and failing to run "analyze" manually afterwards.. is this the case? -- Jesper