Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 21FA81337B2F for ; Wed, 27 Oct 2010 00:57:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 97335-05 for ; Wed, 27 Oct 2010 03:57:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id C0A76133798E for ; Wed, 27 Oct 2010 00:57:43 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o9R3vf7s007675; Tue, 26 Oct 2010 23:57:42 -0400 (EDT) To: Robert Haas cc: Jon Nelson , pgsql-performance@postgresql.org Subject: Re: odd postgresql performance (excessive lseek) In-reply-to: References: <10133.1287498969@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Tue, 26 Oct 2010 23:05:10 -0400" Date: Tue, 26 Oct 2010 23:57:41 -0400 Message-ID: <7674.1288151861@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/459 X-Sequence-Number: 40877 Robert Haas writes: > On Tue, Oct 19, 2010 at 10:36 AM, Tom Lane wrote: >> Those lseeks are for the purpose of detecting the current EOF >> location, ie, finding out whether some other backend has extended the >> file recently.  We could get rid of them, but only at the cost of >> putting in some other communication mechanism instead. > I don't get it. Why would be doing that in a tight loop within a > single backend? Well, we weren't shown any context whatsoever about what the backend was actually doing ... but for example the planner likes to recheck the current physical size of each relation in a query, so that it's working with an up-to-date number. That could probably be avoided, since an estimate would be good enough as long as it wasn't horribly stale. But there are other places that *have* to have the accurate size, like seqscan startup. I doubt it was as tight a loop as all that. It wouldn't be hard at all to have an example where those lseeks are the only operations visible to strace, if all the data the backend needs is in shared buffers. regards, tom lane