mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Improve usage of effective_cache_size parameter by assuming that all the
tables in the query compete for cache space, not just the one we are currently costing an indexscan for. This seems more realistic, and it definitely will help in examples recently exhibited by Stefan Kaltenbrunner. To get the total size of all the tables involved, we must tweak the handling of 'append relations' a bit --- formerly we looked up information about the child tables on-the-fly during set_append_rel_pathlist, but it needs to be done before we start doing any cost estimation, so push it into the add_base_rels_to_query scan.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.81 2006/08/02 01:59:46 joe Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.82 2006/09/19 22:49:53 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -92,7 +92,7 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptKind reloptkind)
|
||||
{
|
||||
case RTE_RELATION:
|
||||
/* Table --- retrieve statistics from the system catalogs */
|
||||
get_relation_info(root, rte->relid, rel);
|
||||
get_relation_info(root, rte->relid, rte->inh, rel);
|
||||
break;
|
||||
case RTE_SUBQUERY:
|
||||
case RTE_FUNCTION:
|
||||
@ -119,6 +119,29 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptKind reloptkind)
|
||||
/* Save the finished struct in the query's simple_rel_array */
|
||||
root->simple_rel_array[relid] = rel;
|
||||
|
||||
/*
|
||||
* If this rel is an appendrel parent, recurse to build "other rel"
|
||||
* RelOptInfos for its children. They are "other rels" because they are
|
||||
* not in the main join tree, but we will need RelOptInfos to plan access
|
||||
* to them.
|
||||
*/
|
||||
if (rte->inh)
|
||||
{
|
||||
ListCell *l;
|
||||
|
||||
foreach(l, root->append_rel_list)
|
||||
{
|
||||
AppendRelInfo *appinfo = (AppendRelInfo *) lfirst(l);
|
||||
|
||||
/* append_rel_list contains all append rels; ignore others */
|
||||
if (appinfo->parent_relid != relid)
|
||||
continue;
|
||||
|
||||
(void) build_simple_rel(root, appinfo->child_relid,
|
||||
RELOPT_OTHER_MEMBER_REL);
|
||||
}
|
||||
}
|
||||
|
||||
return rel;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user