Обсуждение: Accessing base table relational names via RelOptInfo
Hi,
I hope this is the appropriate list to send this to.
Context:
I (grad student) am trying to insert my own cardinality estimates into the optimizer
What I need to do to get there:
I want to be able to programmatically access the relation names inside from inside the calc_joinrel_size_estimate method (in costsize.c) using the RelOptInfo *outer_rel, RelOptInfo *inner_rel arguments. I'm pretty sure I need to use the Relids relids variables in the RelOptInfo struct but I'm not sure where to go from there.
Any help would be much appreciated
Best, Walter
On 7 December 2017 at 09:26, Walter Cai <wzcai92@gmail.com> wrote: > I want to be able to programmatically access the relation names inside from > inside the calc_joinrel_size_estimate method (in costsize.c) using the > RelOptInfo *outer_rel, RelOptInfo *inner_rel arguments. I'm pretty sure I > need to use the Relids relids variables in the RelOptInfo struct but I'm not > sure where to go from there. If you loop through the RelOptInfo->relids with bms_next_member() and lookup the RangeTblEntry from root->simple_rte_array[] you can get the "relid", which is the Oid of the relation. You can then call get_rel_name() on that Oid. You'll also need to ensure the relid actually belongs to a relation, for this check that the RangeTblEntry->rtekind is RTE_RELATION. You might also want to think about schema names since two relations can share the same name in different schemas. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services