mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Fix some planning oversights in postgres_fdw.
Include eval costs of local conditions in remote-estimate mode, and don't assume the remote eval cost is zero in local-estimate mode. (The best we can do with that at the moment is to assume a seqscan, which may well be wildly pessimistic ... but zero won't do at all.) To get a reasonable local estimate, we need to know the relpages count for the remote rel, so improve the ANALYZE code to fetch that rather than just setting the foreign table's relpages field to zero.
This commit is contained in:
@ -456,6 +456,29 @@ appendWhereClause(StringInfo buf,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct SELECT statement to acquire size in blocks of given relation.
|
||||
*
|
||||
* Note: we use local definition of block size, not remote definition.
|
||||
* This is perhaps debatable.
|
||||
*
|
||||
* Note: pg_relation_size() exists in 8.1 and later.
|
||||
*/
|
||||
void
|
||||
deparseAnalyzeSizeSql(StringInfo buf, Relation rel)
|
||||
{
|
||||
Oid relid = RelationGetRelid(rel);
|
||||
StringInfoData relname;
|
||||
|
||||
/* We'll need the remote relation name as a literal. */
|
||||
initStringInfo(&relname);
|
||||
deparseRelation(&relname, relid);
|
||||
|
||||
appendStringInfo(buf, "SELECT pg_catalog.pg_relation_size(");
|
||||
deparseStringLiteral(buf, relname.data);
|
||||
appendStringInfo(buf, "::pg_catalog.regclass) / %d", BLCKSZ);
|
||||
}
|
||||
|
||||
/*
|
||||
* Construct SELECT statement to acquire sample rows of given relation.
|
||||
*
|
||||
|
Reference in New Issue
Block a user