1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Dept of second thoughts: improve the API for AnalyzeForeignTable.

If we make the initially-called function return the table physical-size
estimate, acquire_inherited_sample_rows will be able to use that to
allocate numbers of samples among child tables, when the day comes that
we want to support foreign tables in inheritance trees.
This commit is contained in:
Tom Lane
2012-04-06 16:04:10 -04:00
parent 263d9de66b
commit cea49fe82f
4 changed files with 121 additions and 118 deletions

View File

@ -279,15 +279,19 @@ EndForeignScan (ForeignScanState *node);
<para>
<programlisting>
AcquireSampleRowsFunc
AnalyzeForeignTable (Relation relation);
bool
AnalyzeForeignTable (Relation relation,
AcquireSampleRowsFunc *func,
BlockNumber *totalpages);
</programlisting>
This function is called when <xref linkend="sql-analyze"> is executed on
a foreign table. If the FDW supports collecting statistics for this
foreign table, it should return a pointer to a function that will collect
sample rows from the table. Otherwise, return <literal>NULL</>. If the
FDW does not support collecting statistics for any tables, the
a foreign table. If the FDW can collect statistics for this
foreign table, it should return <literal>true</>, and provide a pointer
to a function that will collect sample rows from the table in
<parameter>func</>, plus the estimated size of the table in pages in
<parameter>totalpages</>. Otherwise, return <literal>false</>.
If the FDW does not support collecting statistics for any tables, the
<function>AnalyzeForeignTable</> pointer can be set to <literal>NULL</>.
</para>
@ -298,18 +302,16 @@ int
AcquireSampleRowsFunc (Relation relation, int elevel,
HeapTuple *rows, int targrows,
double *totalrows,
double *totaldeadrows,
BlockNumber *totalpages);
double *totaldeadrows);
</programlisting>
A random sample of up to <parameter>targrows</> rows should be collected
from the table and stored into the caller-provided <parameter>rows</>
array. The actual number of rows collected must be returned. In
addition, store estimates of the total numbers of live rows, dead rows,
and pages in the table into the output parameters
<parameter>totalrows</>, <parameter>totaldeadrows</>, and
<parameter>totalpages</>. These numbers will be recorded in the table's
<structname>pg_class</> entry for future use.
addition, store estimates of the total numbers of live and dead rows in
the table into the output parameters <parameter>totalrows</> and
<parameter>totaldeadrows</>. (Set <parameter>totaldeadrows</> to zero
if the FDW does not have any concept of dead rows.)
</para>
<para>