Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XAbfh-0000Yg-Nn for pgsql-performance@arkaria.postgresql.org; Fri, 25 Jul 2014 09:20:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XAbfg-0000w3-1f for pgsql-performance@arkaria.postgresql.org; Fri, 25 Jul 2014 09:20:12 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XAbfe-0000vu-Rp for pgsql-performance@postgresql.org; Fri, 25 Jul 2014 09:20:11 +0000 Received: from mout.kundenserver.de ([212.227.17.10]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XAbfX-0000hz-5P for pgsql-performance@postgresql.org; Fri, 25 Jul 2014 09:20:09 +0000 Received: from ayaki.localdomain (58-7-139-127.dyn.iinet.net.au [58.7.139.127]) by mrelayeu.kundenserver.de (node=mreue104) with ESMTP (Nemesis) id 0MAuhQ-1XKTYQ1JvI-009x1Z; Fri, 25 Jul 2014 11:19:59 +0200 Message-ID: <53D2213A.8060101@2ndquadrant.com> Date: Fri, 25 Jul 2014 17:19:54 +0800 From: Craig Ringer Organization: 2nd Quadrant User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Borodin Vladimir , pgsql-performance@postgresql.org Subject: Re: Debugging writing load References: <06E73D38-F341-424F-AD89-8F2DC73B7D79@simply.name> In-Reply-To: <06E73D38-F341-424F-AD89-8F2DC73B7D79@simply.name> X-Enigmail-Version: 1.6 Content-Type: text/plain; charset=windows-1251 Content-Transfer-Encoding: 8bit X-Provags-ID: V02:K0:CiKBqaJAsULJamS39Iln2pHzRmXS+3woqVn6mGTiKJJ 0d2ZAYevCIX6iGQdasG91mb0uUItA0nCkXVRAj1VXMsDJOX6Ds 9j1RZvIEXvZxYxOH/xj0hPJFeUg6jlVXbXABZcYl/C+NC6bE87 ZFh0b+KXWr/Z8e/BYsgr8FQ7aHi3QM8iJJ7tsp2KHHlKiCxb3r GqDMMY5+ioZuzonsWBBzwak8JQlb/2XUiqmUZpkKBwxYAwpfUZ eWjuagZ5QjR73rsU1PQa2C4XUj2Vv4aDId3p97RfRjepdxPEhJ 5mYfnLBhXoLbQYpL8KRTZjXOTJ+b8Jmyo4RzUK1/ggyqw9Ctmg IxfWyIVTubMtRD73bIuE3jGa8aKcqZAbNDDvoQ7gB X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 07/24/2014 10:22 PM, Borodin Vladimir wrote: > Hi all. > > I have a database with quiet heavy writing load (about 20k tps, 5k of > which do writes). And I see lots of writing I/O (I mean amount of data, > not iops) to this database, much more than I expect. My question is how > can I debug what for backend processes do lots of writes to the > $PGDATA/base directory? Below are some details. I'd be using perf for this - if you set tracepoints on writes and flushes you can associate that with the proceses performing the work. That said, the bgwriter and checkpointer will accumulate data from many different backends. perf can't track that back to the origin backend. It's also currently impractical to pluck things like the current_user, statement name, etc from the PostgreSQL process's memory when capturing perf events, so it's still hard to drill down to "this query is causing lots of I/O". > Lsof on several backend processes shows me that backend uses just > database files (tables and indexes) and last xlog file. Is there any way > to understand why is backend writing lots of data to $PGDATA/base > directory? I have tried to use pg_stat_statements for it but I haven’t > found a good way to understand what is happening. Is there a way to see > something like "this backend process has written these pages to disk > while performing this query"? Pg can't keep track of that its self. At most it can track what buffered writes it's issued. The OS might write-merge them, or it might not flush them to disk at all if they're superseded by a later write over the same range. You really need the kernel's help, and that's where perf comes in. I wrote a little about this topic a while ago: http://blog.2ndquadrant.com/tracing-postgresql-perf/ but it's really a bit introductory. -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance