From cea49fe82fedcf125eb99a780099eaf47a326b03 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 6 Apr 2012 16:04:10 -0400 Subject: 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. --- doc/src/sgml/fdwhandler.sgml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/fdwhandler.sgml b/doc/src/sgml/fdwhandler.sgml index 8e7525ab596..2c75b80b303 100644 --- a/doc/src/sgml/fdwhandler.sgml +++ b/doc/src/sgml/fdwhandler.sgml @@ -279,15 +279,19 @@ EndForeignScan (ForeignScanState *node); -AcquireSampleRowsFunc -AnalyzeForeignTable (Relation relation); +bool +AnalyzeForeignTable (Relation relation, + AcquireSampleRowsFunc *func, + BlockNumber *totalpages); This function is called when 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 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 true, and provide a pointer + to a function that will collect sample rows from the table in + func, plus the estimated size of the table in pages in + totalpages. Otherwise, return false. + If the FDW does not support collecting statistics for any tables, the AnalyzeForeignTable pointer can be set to NULL. @@ -298,18 +302,16 @@ int AcquireSampleRowsFunc (Relation relation, int elevel, HeapTuple *rows, int targrows, double *totalrows, - double *totaldeadrows, - BlockNumber *totalpages); + double *totaldeadrows); A random sample of up to targrows rows should be collected from the table and stored into the caller-provided 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 - totalrows, totaldeadrows, and - totalpages. These numbers will be recorded in the table's - 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 totalrows and + totaldeadrows. (Set totaldeadrows to zero + if the FDW does not have any concept of dead rows.) -- cgit v1.2.3