Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOjSD-0008JR-UM for pgsql-general@arkaria.postgresql.org; Tue, 12 Dec 2017 12:14:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOjSD-0002gW-CQ for pgsql-general@arkaria.postgresql.org; Tue, 12 Dec 2017 12:14:33 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eOjSC-0002gM-Uv for pgsql-general@lists.postgresql.org; Tue, 12 Dec 2017 12:14:33 +0000 Received: from mail-qt0-x232.google.com ([2607:f8b0:400d:c0d::232]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eOjS9-0000mo-19 for pgsql-general@lists.postgresql.org; Tue, 12 Dec 2017 12:14:31 +0000 Received: by mail-qt0-x232.google.com with SMTP id f2so46573385qtj.4 for ; Tue, 12 Dec 2017 04:14:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=MD7S3oha4+A7fG/TESri8WOrCAJn4CxXDPG4KB+JYZg=; b=j4634CkrBWoYJT75JN7KsbO7A5VhYK9BoS7p/Z2d/7V5AV8kaitO5fqkzzPBwhgi1L 4uuB9cm5PxD4rmprvt9ivYNtC6be1XYOUqv7QFyx4v9nAtb5R4IXMobLklfUjeTG8ARH qmW/C0uG44Zjf6QDeXwrFE/b641Dc3+4fKvG8GDNReEndFEnjuq0pflfivOyijrO6Xt1 EGf6eHSv0mjC3llX60Lau+6/YVUXfnmoBwTzDjjJbgz28U5HGuVYyNjsIXpkaRRFsFOZ y2ISfBy86O2QNmjbraZwOMev38yb8kzGBz48aStxEGpIctOSGsKcmoypniPuwA7soPR8 fVwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=MD7S3oha4+A7fG/TESri8WOrCAJn4CxXDPG4KB+JYZg=; b=IfJrmbR287V5YZQ9CKA1s+f/0dHI7CkHoCTFUJEuX0eVI1tK3tQt7rHAi2bC251DU6 Aco25y0wrMSF2/P8i8egbcctv2UWpfHHSfAzjSRX1M5F10ooUcAGtOsWCgXCR9N+RRWF G6iy5WNKWKonfVzGzQfDuUlUbmcZyTvgMy8XE88vpFHxxQgMY0uRw/PvV+WKe3MRP1VL X3Ze6WqioANYz8wsQ4q0MeCG2mQbrUTlGsFCnGtmvFAgOuOYbaLdagqo2nqBEQz+a+B5 K7iGjPTICgLROQFYkMz897c/XBRk4hSYZU2VU3aZBWx9iYyNq39jY0llXNTIAeg0Fz3r h1zA== X-Gm-Message-State: AKGB3mJQSDaT+ijMv0Vd1Vp4bHk05RwcJwtWsCkl6dP2C1nBdeuyZHJL ACtLlqM5lCOD0c6oEDhZfmucdWjT X-Google-Smtp-Source: ACJfBoubQP+aXaedfX/raEnMUMEfk1vb0SSUCzc/n8PCjxIyn/jB98u5BGR7UgXRdP4mkF3sUfpFdw== X-Received: by 10.55.50.129 with SMTP id y123mr4726718qky.86.1513080867281; Tue, 12 Dec 2017 04:14:27 -0800 (PST) Received: from [192.168.1.240] (host171.190-229-78.telecom.net.ar. [190.229.78.171]) by smtp.gmail.com with ESMTPSA id h21sm5674084qte.44.2017.12.12.04.14.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 04:14:26 -0800 (PST) Subject: Re: How to know if a database has changed To: Sam Gendler , Andreas Kretschmer Cc: pgsql-general@lists.postgresql.org References: <614bd145-899a-8dc9-154e-a42ad17c2685@a-kretschmer.de> <41f78e39-75cb-9b37-46ac-119cc878f15f@a-kretschmer.de> From: marcelo Message-ID: <5246fbe0-4dc6-8a25-fa44-dcfd1bc87191@gmail.com> Date: Tue, 12 Dec 2017 09:14:23 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------41063526C7EAD553BD1FD3EB" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------41063526C7EAD553BD1FD3EB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi Sam You are right, and here are the reason behind my question: The server where postgres will be installed is not on 24/7. It turns on in the morning and goes off at the end of the day. The idea is that, as part of the shutdown process, a local backup is made. The next day, that backup will be copied to the cloud. In order not to lengthen the shutdown process, we are trying to limit pg_dump to the databases that have had some change, not so much in their schema as in their data. Of course, to add a trigger for every table and CUD operation on every database is not an option. On 11/12/17 23:23, Sam Gendler wrote: > I think there's a more useful question, which is why do you want to do > this?  If it is just about conditional backups, surely the cost of > backup storage is low enough, even in S3 or the like, that a duplicate > backup is an afterthought from a cost perspective? Before you start > jumping through hoops to make your backups conditional, I'd first do > some analysis and figure out what the real cost of the thing I'm > trying to avoid actually is, since my guess is that you are deep into > a premature optimization > here, where either the cost of the duplicate backup isn't > consequential or the frequency of duplicate backups is effectively 0.  > It would always be possible to run some kind of checksum on the backup > and skip storing it if it matches the previous backup's checksum if > you decide that there truly is value in conditionally backing up the > db.  Sure, that would result in dumping a db that doesn't need to be > dumped, but if your write transaction rate is so low that backups end > up being duplicates on a regular basis, then surely you can afford the > cost of a pg_dump without any significant impact on performance? > > On Mon, Dec 11, 2017 at 10:49 AM, Andreas Kretschmer > > wrote: > > > > Am 11.12.2017 um 18:26 schrieb Andreas Kretschmer: > > it's just a rough idea... > > > ... and not perfect, because you can't capture ddl in this way. > > > > Regards, Andreas > > -- > 2ndQuadrant - The PostgreSQL Support Company. > www.2ndQuadrant.com > > > --------------41063526C7EAD553BD1FD3EB Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Sam

You are right, and here are the reason behind my question: The server where postgres will be installed is not on 24/7. It turns on in the morning and goes off at the end of the day. The idea is that, as part of the shutdown process, a local backup is made. The next day, that backup will be copied to the cloud.
In order not to lengthen the shutdown process, we are trying to limit pg_dump to the databases that have had some change, not so much in their schema as in their data.
Of course, to add a trigger for every table and CUD operation on every database is not an option.


On 11/12/17 23:23, Sam Gendler wrote:
I think there's a more useful question, which is why do you want to do this?  If it is just about conditional backups, surely the cost of backup storage is low enough, even in S3 or the like, that a duplicate backup is an afterthought from a cost perspective? Before you start jumping through hoops to make your backups conditional, I'd first do some analysis and figure out what the real cost of the thing I'm trying to avoid actually is, since my guess is that you are deep into a premature optimization here, where either the cost of the duplicate backup isn't consequential or the frequency of duplicate backups is effectively 0.  It would always be possible to run some kind of checksum on the backup and skip storing it if it matches the previous backup's checksum if you decide that there truly is value in conditionally backing up the db.  Sure, that would result in dumping a db that doesn't need to be dumped, but if your write transaction rate is so low that backups end up being duplicates on a regular basis, then surely you can afford the cost of a pg_dump without any significant impact on performance?

On Mon, Dec 11, 2017 at 10:49 AM, Andreas Kretschmer <andreas@a-kretschmer.de> wrote:


Am 11.12.2017 um 18:26 schrieb Andreas Kretschmer:
it's just a rough idea...

... and not perfect, because you can't capture ddl in this way.



Regards, Andreas

--
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com




--------------41063526C7EAD553BD1FD3EB--