X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 96BE9D6D71 for ; Mon, 22 Aug 2005 12:43:01 -0300 (ADT) 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 69655-02 for ; Mon, 22 Aug 2005 15:42:58 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 17292D70A5 for ; Mon, 22 Aug 2005 12:42:57 -0300 (ADT) 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 j7MFfeCY016260; Mon, 22 Aug 2005 11:41:40 -0400 (EDT) To: "Jignesh Shah" Cc: pgsql-performance@postgresql.org Subject: Re: MemoryContextSwitchTo during table scan? In-reply-to: References: Comments: In-reply-to "Jignesh Shah" message dated "Mon, 22 Aug 2005 09:47:38 -0400" Date: Mon, 22 Aug 2005 11:41:40 -0400 Message-ID: <16259.1124725300@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200508/322 X-Sequence-Number: 14069 "Jignesh Shah" writes: > Running a script (available on my blog) I find the following top 5 functions > where it spends most time during a 10 second run of the script It's pretty risky to draw conclusions from only 10 seconds' worth of gprof data --- that's only 1000 samples total at the common sampling rate of 100/sec. If there's one function eating 90% of the runtime, you'll find out, but you don't have enough data to believe that you know what is happening with resolution of a percent or so. I generally try to accumulate several minutes worth of CPU time in a gprof run. > MemoryContextSwitchTo and LockBuffer itself takes 15% of the total time of > the query. I was expecting "read" to be the slowest part (biggest component) > but it was way down in the 0.4% level. You do know that gprof counts only CPU time, and only user-space CPU time at that? read() isn't going to show up at all. It's fairly likely that your test case is I/O bound and that worrying about CPU efficiency for it is a waste of time anyway. regards, tom lane