From: | Corey Huinker <corey(dot)huinker(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Import Statistics in postgres_fdw before resorting to sampling. |
Date: | 2025-08-12 17:02:39 |
Message-ID: | CADkLM=chrYAx=X2KUcDRST4RLaRLivYDohZrkW4LLBa0iBhb5w@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Attached is my current work on adding remote fetching of statistics to
postgres_fdw, and opening the possibility of doing so to other foreign data
wrappers.
This involves adding two new options to postgres_fdw at the server and
table level.
The first option, fetch_stats, defaults to true at both levels. If enabled,
it will cause an ANALYZE of a postgres_fdw foreign table to first attempt
to fetch relation and attribute statistics from the remote table. If this
succeeds, then those statistics are imported into the local foreign table,
allowing us to skip a potentially expensive sampling operation.
The second option, remote_analyze, defaults to false at both levels, and
only comes into play if the first fetch succeeds but no attribute
statistics (i.e. the stats from pg_stats) are found. If enabled then the
function will attempt to ANALYZE the remote table, and if that is
successful then a second attempt at fetching remote statistics will be made.
If no statistics were fetched, then the operation will fall back to the
normal sampling operation per settings.
Note patches 0001 and 0002 are already a part of a separate thread
https://www.postgresql.org/message-id/flat/CADkLM%3DcpUiJ3QF7aUthTvaVMmgQcm7QqZBRMDLhBRTR%2BgJX-Og%40mail.gmail.com
regarding a bug (0001) and a nitpick (0002) that came about as a
side-effect to this effort, and but I expect those to be resolved one way
or another soon. Any feedback on those two can be handled there.
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Fix-remote-sampling-tests-in-postgres_fdw.patch | text/x-patch | 3.6 KB |
v1-0002-Use-psql-vars-to-eliminate-the-need-for-DO-blocks.patch | text/x-patch | 7.1 KB |
v1-0003-Add-remote-statistics-fetching-to-postgres_fdw.patch | text/x-patch | 37.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2025-08-12 17:10:57 | Re: Parallel Apply |
Previous Message | Tomas Vondra | 2025-08-12 16:53:13 | Re: index prefetching |