Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aguPJ-0007sD-TI for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Mar 2016 13:25:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aguPI-0005Ko-Sd for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Mar 2016 13:25:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aguPI-0005Kh-EX for pgsql-bugs@postgresql.org; Fri, 18 Mar 2016 13:25:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aguPG-0002XE-0Q for pgsql-bugs@postgresql.org; Fri, 18 Mar 2016 13:25:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u2IDPViK015622; Fri, 18 Mar 2016 09:25:31 -0400 From: Tom Lane To: matvejchikov@gmail.com cc: pgsql-bugs@postgresql.org Subject: Re: Incorrect accounting (n_tup_ins) of non-inserted rows In-reply-to: References: Comments: In-reply-to Ilya Matveychikov message dated "Fri, 18 Mar 2016 12:54:20 +0300" Date: Fri, 18 Mar 2016 09:25:31 -0400 Message-ID: <15621.1458307531@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Ilya Matveychikov writes: > Seems that accounting of insertions with `n_tup_ins` not correct in > case of insertion errors cause by constraints checking (duplicate key > value violates unique constraint): You already found one of the many code comments indicating that this is the intended behavior: > CODE REFERENCE (src/backend/postmaster/pgstat.c) > /* count attempted actions regardless of commit/abort */ > So, is this behavior normal or probably needs to be fixed? No, it's not a bug, and it's not going to be fixed. For many of the intended applications of those counts (e.g, determining whether autovacuum/autoanalyze is needed), this is the correct behavior and ignoring actions of failed transactions would be incorrect. The live/dead tuple counts do attempt to take transaction success into account; perhaps looking at those would be more helpful for your use-case? regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs