Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tzjkI-005vAH-Jz for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Apr 2025 22:06:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tzjkH-0078mv-47 for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Apr 2025 22:06:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tzjkG-0078mm-K9 for pgsql-hackers@lists.postgresql.org; Tue, 01 Apr 2025 22:06:08 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tzjkB-002puV-22 for pgsql-hackers@lists.postgresql.org; Tue, 01 Apr 2025 22:06:08 +0000 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-30185d00446so502851a91.0 for ; Tue, 01 Apr 2025 15:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1743545162; x=1744149962; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=wRp3NkNlMPxi/3COXrRfwSZ8t35hevI4hahLHsF6Y+o=; b=IeTjXaiElrv6P7TRU4+JcimsESQm5RHHI8cIcm/VEc/I8D9n7N5Cq3xgn5ra51F+v2 OQVPO8ZXCUxCGFiiEY9rUXuhpkWYVgiWPNGUr4ILjIOSOpJugJoNIYvcpCwccCg7hGl9 GLWMcGM5gI6QjLfBs54yuaFGjyHnTCaMYGI3Yat6d6QIPF47xUmA+2Tkc3b5q1BkiJ3h MV92Bja52G/lrTDVeQNybY2TgtCHQoVcTLvAF+Uu3CWVSa70rcYsf+c6Y+HFlTJSGloq 8ddXWr3y4bOXHslUGrG4WCjU+l+bBT0u9SlGKKRB5S2ty7A+EfCXldHg5UUBcyVbg1qb x1Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743545162; x=1744149962; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wRp3NkNlMPxi/3COXrRfwSZ8t35hevI4hahLHsF6Y+o=; b=FY/Nsi6ZRgYcR1ySOH4h85tM178j5nh0F+P89hYLYZK9n9fz8IF3N8imD++jxq89Tb XFHk1zXzqFQN8K0chxSGOL/RLP4b7cUn+ylqK037u/iJ3nyTBAdN3qVsLwAsq3gK/9Tp aUikoNDNtKMDjosNRAuhZNwIyTTfpGjy+CgjTuOlGnZRQVE8JpBsDkvqrdtWOzzGjO4a asnkUvnhTzkVFqS+FSvAX2RClgXoNnYIW/jeg1gG7/IW8x9hxqb0b57oJX30bTr5qVYq 79nzBEf/hBTfVTFtz1yxOugH8Z6KlUf6+Uyyr9LxoNvUNFqSiY6OzpOAWiox43JO7S0f xjiA== X-Forwarded-Encrypted: i=1; AJvYcCWc6qep3oTeRGQFheUCsPNvpwbIv21v605dKsiUu8Vjp3oUYg9mFLuNT2OpaVIaXsumskzFxFBs57Td5Cuo@lists.postgresql.org X-Gm-Message-State: AOJu0YzzA6CBIR1yfbC4OCFlmCPuLvVTH2IYffAov1Hct/FQ2dbrT9yq +ubQqMj3d8v9/IhcLuZFGneEJWh4YryqThCVktOatadu9qWldGOB2oUOLJ5jBg== X-Gm-Gg: ASbGncu4GFmKYEAaVFouIIUPT/Fl6ohoZOH2If0DMw4G+H0CGP6GvaT61Atkfgba8Fr Tw69SlTnVZE0gEZXw/ARuHH9+gMiMK+g5dgolWSxDisPdNEaGMEGx8FNdb7oSf7LEmtQC9YGxqh JfxA6fCPBvO6BhRdJT6lVU8A3j0ZNWRtAI3oIYKeGP41ZhFgyb7ioQx8w4n9eOCbXmbA0tiOv9w iARCJUvIoWv0gMQPUeRYjCKGMQQ4qR6YnLuog7HA5TpVPkCf0J+B+p9ewq7sVo+b2ePb1allxic rdsjaQhjsAqXcHpTCRrYomawmU7zlpmG4xB5B/gQ19J5 X-Google-Smtp-Source: AGHT+IG43BDT2pokrFEziP7z7nt2dDpvTcNSQaoJxum5GDK7mmQdcHgkR9eEFkClpQ5tqjJpzk6yyw== X-Received: by 2002:a17:90b:4984:b0:2fa:2133:bc87 with SMTP id 98e67ed59e1d1-3056b708880mr2027145a91.6.1743545161698; Tue, 01 Apr 2025 15:06:01 -0700 (PDT) Received: from [172.24.2.43] ([12.126.244.130]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3056f881599sm72228a91.23.2025.04.01.15.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 15:06:01 -0700 (PDT) Message-ID: <88af35fe0ff24cc4e0700b841aa60a0865f11648.camel@j-davis.com> Subject: Re: Statistics Import and Export From: Jeff Davis To: Nathan Bossart , Corey Huinker Cc: Robert Treat , Robert Haas , Andres Freund , Tom Lane , Michael Paquier , jian he , Bruce Momjian , Matthias van de Meent , Magnus Hagander , Stephen Frost , Ashutosh Bapat , Peter Smith , PostgreSQL Hackers , alvherre@alvh.no-ip.org Date: Tue, 01 Apr 2025 15:05:59 -0700 In-Reply-To: References: <0576fa4dbd6e62e027b41e0ef9254896540f1cb4.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2025-04-01 at 13:44 -0500, Nathan Bossart wrote: > Apologies for the noise.=C2=A0 I noticed one more way to simplify 0002.= =C2=A0 > As > before, there should be no functional differences. To restate the problem: one of the problems being solved here is that the existing code for custom-format dumps calls WriteToc twice. That was not a big problem before this patch, when the contents of the entries was easily accessible in memory. But the point of 0002 is to avoid keeping all of the stats in memory at once, because that causes bloat; and instead to query it on demand. In theory, we could fix the pre-existing code by making the second pass able to jump over the other contents of the entry and just update the data offsets. But that seems invasive, at least to do it properly. 0001 sidesteps the problem by skipping the second pass if data's not being dumped (because there are no offsets that need updating). The worst case is when there are a lot of objects with a small amount of data. But that's a worst case for stats in general, so I don't think that needs to be solved here. Issuing the stats queries twice is not great, though. If there's any non-deterministic output in the query, that could lead to strangeness. How bad can that be? If the results change in some way that looks benign, but changes the length of the definition string, can it lead to corruption of a ToC entry? I'm not saying there's a problem, but trying to understand the risk of future problems. For 0003, it makes an assumption about the way the scan happens in WriteToc(). Can you add some additional sanity checks to verify that something doesn't happen in a different order than we expect? Also, why do we need the clause "WHERE s.tablename =3D ANY($2)"? Isn't that already implied by "JOIN unnest($1, $2) ... s.tablename =3D u.tablename"? Regards, Jeff Davis