Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gAoLJ-0007Cy-0t for pgsql-general@arkaria.postgresql.org; Fri, 12 Oct 2018 03:42:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gAoLE-0001Xn-6B for pgsql-general@arkaria.postgresql.org; Fri, 12 Oct 2018 03:42:20 +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.89) (envelope-from ) id 1gAoLD-0001Xg-UY for pgsql-general@lists.postgresql.org; Fri, 12 Oct 2018 03:42:19 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by magus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gAoLB-0000eu-07 for pgsql-general@postgresql.org; Fri, 12 Oct 2018 03:42:18 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id F3AFE4063E; Fri, 12 Oct 2018 05:42:14 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id zMv_qKKdQbEM; Fri, 12 Oct 2018 05:42:13 +0200 (CEST) Message-ID: Subject: Re: how to identify the timeline of specified recovery_target_time when do multiple PITR From: Laurenz Albe To: magodo , pgsql-general@postgresql.org Date: Fri, 12 Oct 2018 05:42:12 +0200 In-Reply-To: <32dd51b8c3848258511d97597a15292b2e97b7e0.camel@sina.com> References: <29dd7b5cf905ee53026f96b78a505f1b76b6031b.camel@sina.com> <0c552a0ee114314ceb026d65f75a98df3e8d22ff.camel@cybertec.at> <34d85bfc77e9a63890e28ea13953c30508233469.camel@cybertec.at> <41a74e2ac23015149bc98631b8dcac0fdb6b6a51.camel@sina.com> <11f07b3786a54bf74a7ce5970422a0b22c3ffb50.camel@sina.com> <25a3b6f0128ed10635267488d689a75055958208.camel@cybertec.at> <32dd51b8c3848258511d97597a15292b2e97b7e0.camel@sina.com> Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk magodo wrote: > > How can you know how many WAL segments there are on timeline 1, and if > > there is one that extends past 2018-10-11 12:00:00 or not? > > This is the exact problem I want to figure out. My approach is as you said, > I will parse each archived WAL segment via `pg_xlogdump -r Transaction`, > and try to find the first least earliest WAL against the specified time. > This is a linear search, which has complexity of O(n). That means that the time spent grows linearly, but it is still a lot of time if there are a lot of WAL archives. > So if you want to recover to that point of time, how do you choose the timeline? PostgreSQL doesn't provide auch a functionality, and I can think of three reasons: 1) the high cost as mentioned above 2) during archive recovery, it does not happen very often that you have to choose between timelines at all. It is more typical for streaming replication. 3) nobody saw a use case for such a functionality If you really need this functionality, you'll have to write it yourself. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com