Clarify the 'rows' parameter in create_append_path
authorDavid Rowley <drowley@postgresql.org>
Thu, 15 Feb 2024 00:13:31 +0000 (13:13 +1300)
committerDavid Rowley <drowley@postgresql.org>
Thu, 15 Feb 2024 00:13:31 +0000 (13:13 +1300)
This is extracted from a larger patch to improve the UNION planner.
While working on that, I found myself having to check what the 'rows'
parameter is for.  It's not obvious that passing a negative number is the
way to have the rows estimate calculated and to find that out you need
to read code in create_append_path() and in cost_append().

Discussion: https://postgr.es/m/CAApHDvpb_63XQodmxKUF8vb9M7CxyUyT4sWvEgqeQU-GB7QFoQ@mail.gmail.com

src/backend/optimizer/util/pathnode.c

index 2e1ec41a5412acbfd6fae5e5297119f734a13153..b3902b003290ba1265204309cba9f91c1eab8528 100644 (file)
@@ -1237,6 +1237,10 @@ create_tidrangescan_path(PlannerInfo *root, RelOptInfo *rel,
  *
  * Note that we must handle subpaths = NIL, representing a dummy access path.
  * Also, there are callers that pass root = NULL.
+ *
+ * 'rows', when passed as a non-negative number, will be used to overwrite the
+ * returned path's row estimate.  Otherwise, the row estimate is calculated
+ * by totalling the row estimates from the 'subpaths' list.
  */
 AppendPath *
 create_append_path(PlannerInfo *root,