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.96) (envelope-from ) id 1wan3Q-0023jJ-1Z for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Jun 2026 04:11:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wan3N-000ZVl-0l for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Jun 2026 04:11:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wan3M-000ZVb-2T for pgsql-hackers@lists.postgresql.org; Sat, 20 Jun 2026 04:11:32 +0000 Received: from mail-dl1-x1229.google.com ([2607:f8b0:4864:20::1229]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wan3K-00000001Eli-41ld for pgsql-hackers@postgresql.org; Sat, 20 Jun 2026 04:11:31 +0000 Received: by mail-dl1-x1229.google.com with SMTP id a92af1059eb24-13988680a69so6385310c88.0 for ; Fri, 19 Jun 2026 21:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781928689; cv=none; d=google.com; s=arc-20240605; b=RDTC+xphuN0lARuZ+Ku9ZRBIw7hXJtor4X7y6mSW+JEfZ4XL6Tf9USFoRGH/bubbXp 9uB89Z79eru5/FGu1ne0CqmRuc6M5w6xKMWc6LFeC6sZdxrdbU7WGMxo/PMjXpNLDaKH DhTzCSaOMy8j0N/cEIYXx32cSo5ZSu3Sy4/ueGzlel9y6mMguoJp7eM39r33ELzhsNl7 18ynOZGhsTL+p5kAkDzT2ppJx5aaXNmO2gW9bSKTohW+THvfLWya+te9TGipzlvcQ2Q9 iWNzC8ksvm8ZvkA+DJN0cX7v+7YWpHwuid5s+qa6KBKyauwXjZM4UQ9v7d6eM22JgfHX ujdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=agRTMPdEU3HWEse1vpb1G3cAqIoybO57olP+QBU/eYQ=; fh=lUqSxMx2QCIhJedvyb8/tZNDUecO4CMOuHzTFow+d7Q=; b=HYGmdWUGAzEDQaCywV0pY6R/ulEls+3r8NZnMTQKHTYV8nwurdd9U6XYttQLnknw/Q 7kbLOheV8eh3g+kCnkcm4c/R+4ZbFT3YiIsjjeaVRK1DCaykNpPhLUrcAT4/xIElkxs6 GorwAVo6/c/2Wcg/GEfrFuim2sY4nUAS8J52qeJ6mG79pv7Tr48N7GACSGFOUEufPvJG yi419wRZ2VjLYriZ9nqZwaK0hF3zIH+65bc31yWe5dxpSV4AdtVwAhYEkzTwG+nEiowu WyWq5kzL4D0VcVKs+yB3Vi8tyaaoi/L2OT/RKnnk1/riDcnzgajr7D6vGrQjuVWYHQYG HLUQ==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781928689; x=1782533489; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=agRTMPdEU3HWEse1vpb1G3cAqIoybO57olP+QBU/eYQ=; b=dJemfyc9F/1PTDB9d75MPnpH+BVf2cl+UCo7X0wXkWGGD+fCo/yo27jG4Ikad7BdAd E+qHc4k03VpLqD2IJjSpWA7dVwKUxL+RSrrlUgl++qkpSo9AI6DNr+jo6tOSqVTI/Lij ZDutYsoys6y+5HQqIPrvIZRT1P2V/GKyyzLzkWAfFCXlPRvNYZoKyDBTk5NwKmninAUj pllFKTz9uzNU0lzx/csZTYd4V4I+Ww+PIMt8OztdwdL1K4yNzbty2afIPENStgK2+9Uu DK8HEXOJbhqiSf/mzZIxWbOLQCz7ghC+Mz+POmKQ9iKeC24emzhV5KxmAkZ+Jc6OVTIT 5YMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781928689; x=1782533489; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=agRTMPdEU3HWEse1vpb1G3cAqIoybO57olP+QBU/eYQ=; b=OImg6xxRHE+m7vSWuaTwhV4ULVI5Gx5QKOuWhKxXZ+rzC/GxJTznoNfHiQDRk5u/hx LwgQIOyKyWPR1c3ADSulr7kd+f5Zc6JqPIRxJ0RqtbXmaPRW6JD2oARjeHKukSgVahai BzBZ+CkyJS8/NF4QY/rvxqJo/iMIqfY9wpfDmYF3d+ME+Ebz+s8RBaCoBc6SX3q1lwjs PLwVEtRUBRud6LBrGQgQhJf9vULsAnLL5tjO/8mg9NNXDH0ifctzOSXqTRtVA3EmZxO3 V7n5IFltbNko7SSRgXXP+/bMjs3thvTYO9K9HFCpBKcsU8wV29fI6lv9s+p3x+ygvEaj RQrw== X-Forwarded-Encrypted: i=1; AFNElJ+2I3Ym/3k0WxIMPuSwFQLvZGR6wFwbIK8LFZHTvw2byEvxU5VMk2AmFibfAlzqtHBD91ZNdZNeWelM93vM@postgresql.org X-Gm-Message-State: AOJu0YxVF2oHyDM3uh8BHq9SkEsfnuL6PkCkMSWoVdT9gy+iXb4quOTq OKj+fEk+bySdridpfx8g4TFEM/Pzgstz+jKPyP/522O8xjR0KV6vURkj55fO7KcMkNrND1JaTEt vFJY6+2xUdQqZHpJFuJjeR+k7+6JK1tg= X-Gm-Gg: AfdE7cm4KbOjvcpvFFfBCQVcnN3hGzQN///HVb8i1fKJpWQ4lT28YF2L2Rww27uskH8 lCP+zBBS481X3DH/g5oAcVty1SA/xKMmXwd157CYLtXng2GQ00QMXmSNwd1xLMta5OMcazVn0Ij /KBZD/efA8Q1JCp0PsDZxcih8tk+xjER4HUf/IYfc+YjaJ5ZgkfYjqfPM2QkrI7xodwhXRFZ0XJ T1JWX4xTalV2oAlJ2foJNQoe4Wxw+cc0HfVWi4ZM6QoK6OQKH9ZBZVdXrOn8KTeTCxJheXnq+FD 7xpoQDDK2Efm6JBwG4GujAC0YHElPGDQsAS4YoCQdAdfjQK4e9SYTKrJPvcZBmb44rbz3kFnvkZ Vyc9hyG/EplY0KA== X-Received: by 2002:a05:7022:ea2f:b0:135:d749:574f with SMTP id a92af1059eb24-139a2060a0amr4659789c88.13.1781928688640; Fri, 19 Jun 2026 21:11:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Corey Huinker Date: Sat, 20 Jun 2026 00:11:17 -0400 X-Gm-Features: AVVi8Cd_123hxyse46KCmVCThePZGTiBJO3N0uVfFsGkMKac1ctBWf4XGM3WmkM Message-ID: Subject: Re: use of SPI by postgresImportForeignStatistics To: Robert Haas Cc: Etsuro Fujita , "pgsql-hackers@postgresql.org" Content-Type: multipart/alternative; boundary="000000000000806a840654a79a6a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000806a840654a79a6a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jun 19, 2026 at 9:45=E2=80=AFAM Robert Haas = wrote: > On Thu, Jun 18, 2026 at 5:23=E2=80=AFPM Corey Huinker > wrote: > > To be clear, this solves the SPI problem, but questions about the desig= n > of attribute_statistics_update() and relation_statistics_update() remain, > but those concerns are now isolated within their respective files > attribute_stats.c and relation_stats.c. The inefficiencies therein aren't > really in a critical path, so if we wanted to leave them be until v20 the= y > could, but if time allows I'd at least like try unwinding some of that. B= ut > first, let's get SPI out of postgres_fdw.c. > > I think that's the right order of priority, but I don't think that > having import_attribute_statistics construct an fcinfo is great. > Me either, I'm looking at "phase 2" already where relation/attribute_statistics_update becomes a conventional function, and pg_clear_attribute_stats and pg_restore_attribute_stats (and their relstats equivalents) marshal their parameters to call that instead. > Ideally, attribute_statistics_update would call > import_attribute_statistics rather than the other way around. > I think we're mostly on the same page. If we require the caller to understand the stats data structures to a greater level of detail, and require it to do the transformations to the proper input types (BlockNumbers, floats, float arrays, cstrings for anyarray, etc), then the import_attribute_statistics functon and the new attribute_statistics_update would be one-in-the-same. The v1 patch leaned heavily (perhaps too far) towards letting the caller pass along string values fetched via PQgetvalue() from a pg_stats without modification. --000000000000806a840654a79a6a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Jun 19, 2026 at 9:45=E2=80=AFAM Rober= t Haas <robertmhaas@gmail.com> wrote:
On= Thu, Jun 18, 2026 at 5:23=E2=80=AFPM Corey Huinker <corey.huinker@gmail.com> w= rote:
> To be clear, this solves the SPI problem, but questions about the desi= gn of attribute_statistics_update() and relation_statistics_update() remain= , but those concerns are now isolated within their respective files attribu= te_stats.c and relation_stats.c. The inefficiencies therein aren't real= ly in a critical path, so if we wanted to leave them be until v20 they coul= d, but if time allows I'd at least like try unwinding some of that. But= first, let's get SPI out of postgres_fdw.c.

I think that's the right order of priority, but I don't think that<= br> having import_attribute_statistics construct an fcinfo is great.

Me either, I'm looking at "phase 2"= already where relation/attribute_statistics_update becomes a conventional = function, and pg_clear_attribute_stats and pg_restore_attribute_stats (and = their relstats equivalents) marshal their parameters to call that instead.<= /div>
=C2=A0
Ideally, attribute_statistics_update would call
import_attribute_statistics rather than the other way around.

I think we're mostly on the same page. If we req= uire the caller to understand the stats data structures to a greater level = of detail, and require it to do the transformations to the proper input typ= es (BlockNumbers, floats, float arrays, cstrings for anyarray, etc), then t= he import_attribute_statistics functon and the new attribute_statistics_upd= ate would be one-in-the-same. The v1 patch leaned heavily (perhaps too far)= towards letting the caller pass along string values fetched via PQgetvalue() from a pg_stats without = modification.
--000000000000806a840654a79a6a--