diff --git a/scripts/osm2pgsql-replication b/scripts/osm2pgsql-replication index fa9be50db..d9856f977 100755 --- a/scripts/osm2pgsql-replication +++ b/scripts/osm2pgsql-replication @@ -365,6 +365,7 @@ def update(conn, args): return 1 base_url, seq, ts = cur.fetchone() + initial_local_timestamp = ts LOG.info("Using replication service '%s'.", base_url) local_db_age_sec = int((dt.datetime.now(dt.timezone.utc) - ts).total_seconds()) LOG.info("Local database is at sequence %d, which is data up until %s ago (%d seconds ago, %s).", @@ -396,6 +397,8 @@ def update(conn, args): int((current.timestamp - ts).total_seconds()), ) + update_started = dt.datetime.now(dt.timezone.utc) + if args.diff_file is not None: outfile = Path(args.diff_file) else: @@ -454,6 +457,23 @@ def update(conn, args): if args.once: break + + update_duration_sec = (dt.datetime.now(dt.timezone.utc) - update_started).total_seconds() + with conn.cursor() as cur: + cur.execute(sql.SQL('SELECT * FROM {}').format(args.table)) + if cur.rowcount != 1: + LOG.fatal("Updates not set up correctly. Run 'osm2pgsql-updates init' first.") + return 1 + + _base_url, _seq, current_local_timestamp = cur.fetchone() + + total_applied_changes_duration_sec = (current_local_timestamp - initial_local_timestamp).total_seconds() + LOG.info("It took %s (%d sec) to apply %s (%d sec) of changes. This is a speed of ×%.1f.", + pretty_format_timedelta(update_duration_sec), int(update_duration_sec), + pretty_format_timedelta(total_applied_changes_duration_sec), int(total_applied_changes_duration_sec), + total_applied_changes_duration_sec / update_duration_sec + ) + return 0 def get_parser():