Re: Import Statistics in postgres_fdw before resorting to sampling.
| От | Matheus Alcantara |
|---|---|
| Тема | Re: Import Statistics in postgres_fdw before resorting to sampling. |
| Дата | |
| Msg-id | DFJGQC8ROZK0.1IVQDK0Z3H838@gmail.com обсуждение исходный текст |
| Ответ на | Re: Import Statistics in postgres_fdw before resorting to sampling. (Corey Huinker <corey.huinker@gmail.com>) |
| Список | pgsql-hackers |
On Wed Jan 7, 2026 at 3:04 AM -03, Corey Huinker wrote: > Anyway, here's v8, incorporating the documentation feedback and Matheus's > notes. > +CREATE FOREIGN TABLE remote_analyze_ftable (id int, a text, b bigint) + SERVER loopback + OPTIONS (table_name 'remote_analyze_table', + fetch_stats 'true', + remote_analyze 'true'); I think that it would be good also to have a test case where remote_analyze is false. The test could manually execute an ANALYZE on the target table and ensure that an ANALYZE on the foreign table fetch the statistics correctly. --- If the table don't have columns it fails to fetch the statistics with remote_analyze=false even if the target table has statistics: ERROR: P0002: Failed to import statistics from remote table public.t2, no statistics found. And if I set remote_analyze=true it fails with the following error: postgres=# analyze t2_fdw; ERROR: 08006: could not obtain message string for remote error CONTEXT: remote SQL command: SELECT DISTINCT ON (s.attname) attname, s.null_frac, s.avg_width, s.n_distinct, s.most_common_vals, s.most_common_freqs, s.histogram_bounds, s.correlation, s.most_common_elems, s.most_common_elem_freqs, s.elem_count_histogram, s.range_length_histogram, s.range_empty_frac, s.range_bounds_histogram FROM pg_catalog.pg_stats AS s WHERE s.schemaname = $1 AND s.tablename = $2 AND s.attname = ANY($3::text[]) ORDER BY s.attname, s.inherited DESC LOCATION: pgfdw_report_internal, connection.c:1037 --- If we try to run ANALYZE on a specific table column that don't exists we get: postgres=# analyze t(c); ERROR: 42703: column "c" of relation "t" does not exist LOCATION: do_analyze_rel, analyze.c:412 With fetch_stats=false we get the same error: postgres=# ALTER FOREIGN TABLE t_fdw OPTIONS (add fetch_stats 'false'); ALTER FOREIGN TABLE postgres=# ANALYZE t_fdw(c); ERROR: 42703: column "c" of relation "t_fdw" does not exist But with fetch_stats=true we get a different error: postgres=# ALTER FOREIGN TABLE t_fdw OPTIONS (drop fetch_stats); ALTER FOREIGN TABLE postgres=# ANALYZE t_fdw(c); ERROR: P0002: Failed to import statistics from remote table public.t, no statistics found. Should all these errors be consistency? --- I hope that these comments are more useful now. Thanks. -- Matheus Alcantara EDB: https://www.enterprisedb.com
В списке pgsql-hackers по дате отправления: