Re: Retire has_multiple_baserels() - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Re: Retire has_multiple_baserels()
Date
Msg-id CAJ7c6TNSimB6_y-o4ojNT+Hd2hOsVoZrpz9iR-3kgu54mS=7Eg@mail.gmail.com
Whole thread Raw
In response to Retire has_multiple_baserels()  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: Retire has_multiple_baserels()
Re: Retire has_multiple_baserels()
List pgsql-hackers
Hi,

> The function has_multiple_baserels() is used in set_subquery_pathlist()
> to check and see if there are more than 1 base rel, by looping through
> simple_rel_array[].  I think one simpler way to do that is to leverage
> root->all_baserels by
>
>     bms_membership(root->all_baserels) == BMS_MULTIPLE
>
> all_baserels is computed in deconstruct_jointree (v16) or in
> make_one_rel (v15 and earlier), both are before we generate access paths
> for subquery RTEs, and it contains all base rels (but not "other" rels).
> So it should be a suitable replacement.  I doubt that there would be any
> measurable performance gains.  So please consider it cosmetic.
>
> I've attached a patch to do that.  Any thoughts?

I used the following patch to double check that nothing was missed:

```
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -2207,8 +2207,13 @@ has_multiple_baserels(PlannerInfo *root)
                /* ignore RTEs that are "other rels" */
                if (brel->reloptkind == RELOPT_BASEREL)
                        if (++num_base_rels > 1)
+                       {
+
Assert(bms_membership(root->all_baserels) == BMS_MULTIPLE);
                                return true;
+                       }
        }
+
+       Assert(bms_membership(root->all_baserels) != BMS_MULTIPLE);
        return false;
 }
```

It wasn't. The patch LGTM.

-- 
Best regards,
Aleksander Alekseev



pgsql-hackers by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: Add const to values and nulls arguments
Next
From: Aleksander Alekseev
Date:
Subject: Re: Advice about preloaded libraries