From: | Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | James Finnerty <jfinnert(at)amazon(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: postgres_fdw: using TABLESAMPLE to collect remote sample |
Date: | 2023-01-05 20:43:42 |
Message-ID: | 3d719e62-64d2-5184-eebf-6128bcb398e2@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
here's two minor postgres_fdw patches, addressing the two issues
discussed last week.
1) 0001-Fix-stale-comment-in-postgres_fdw.patch
The first one cleans up the comment referencing the sample rate
adjustment. While doing that, I realized without the adjustment we
should never get sample_rate outside the valid range because we do:
if ((reltuples <= 0) || (targrows >= reltuples))
method = ANALYZE_SAMPLE_OFF;
So I removed the clamping, or rather replaced it with an assert.
2) 0002-WIP-check-relkind-in-FDW-analyze.patch
The second patch adds the relkind check, so that we only issue
TABLESAMPLE on valid relation types (tables, matviews). But I'm not sure
we actually need it - the example presented earlier was foreign table
pointing to a sequence. But that actually works fine even without this
patch, because fore sequences we have reltuples=1, which disables
sampling due to the check mentioned above (because targrows >= 1).
The other issue with this patch is that it seems wrong to check the
relkind value locally - instead we should check this on the remote
server, because that's where we'll run TABLESAMPLE. Currently there are
no differences between versions, but what if we implement TABLESAMPLE
for another relkind in the future? Then we'll either fail to use
sampling or (worse) we'll try using TABLESAMPLE for unsupported relkind,
depending on which of the servers has newer version.
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachment | Content-Type | Size |
---|---|---|
0002-WIP-check-relkind-in-FDW-analyze.patch | text/x-patch | 3.2 KB |
0001-Fix-stale-comment-in-postgres_fdw.patch | text/x-patch | 1.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-01-05 21:05:11 | Re: postgres_fdw: using TABLESAMPLE to collect remote sample |
Previous Message | Corey Huinker | 2023-01-05 20:19:54 | Re: Generate pg_stat_get_xact*() functions with Macros |