Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 55543F64990 for ; Tue, 24 Jul 2012 14:21:56 -0300 (ADT) Received: from archon2012.plus.com ([80.229.41.160] helo=mail.archonet.com) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Stiny-0004Ib-9q for pgsql-performance@postgresql.org; Tue, 24 Jul 2012 17:21:55 +0000 Received: from [192.168.1.13] (ariel.office.archonet.com [192.168.1.13]) by mail.archonet.com (Postfix) with ESMTP id 3E21F2C4DD6; Tue, 24 Jul 2012 18:21:38 +0100 (BST) Message-ID: <500ED9A2.3040101@archonet.com> Date: Tue, 24 Jul 2012 18:21:38 +0100 From: Richard Huxton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4 MIME-Version: 1.0 To: Aleksei Arefjev CC: pgsql-performance@postgresql.org Subject: Re: transactions start time References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201207/307 X-Sequence-Number: 47488 On 24/07/12 12:14, Aleksei Arefjev wrote: > Hi, > > In statistical reports gathered by PgBadger on our PostgreSQL databases > almost always we have in "Queries that took up the most time" report > table information about transactions start time ('BEGIN;' command). > Something like that in example below: > > 2 3h34m52.26s 48,556,167 0.00s BEGIN; > > 0.82s | BEGIN; > 0.82s | BEGIN; > 0.82s | BEGIN; > 0.81s | BEGIN; > 0.81s | BEGIN; > 0.81s | BEGIN; > 0.80s | BEGIN; > 0.80s | BEGIN; > 0.79s | BEGIN; > 0.79s | BEGIN; I'm not sure if I'm reading this right, but are there more than 48 million BEGINs that took 0s each (presumably rounded down) and then a handful taking about 0.8s? If so, then it's likely nothing to do with the BEGIN and just that the machine was busy doing other things when you started a transaction. > Databases placed on different hardware, OS - Debian GNU/Linux, > PostgreSQL 9.1 > > So, questions are: > 1. Is this a normal situation with transactions start time ( BEGIN method) ? See above > 2. How can we reduce transactions start time if it's possible in principle? Below 0.00? Probably not > 3. What happens in PostgreSQL on transaction starting time? Can someone > describe this process in detail? (of course, I saw in PostgreSQL source > code, for example, definition such kind functions, like StartTransaction > function, but it's not so easy to understand for third-party researcher, > that all of these operations mean in real for performance) Well there are two important things to understand: 1. All* commands run in a transaction 2. I think most of the work in getting a new snapshot etc gets pushed back until it's needed. So - the overall impact of issuing BEGIN should be close to zero. -- Richard Huxton Archonet Ltd