Skip to content

Fix invariants optimization involving views (#7388)#7390

Merged
dyemanov merged 1 commit intomasterfrom
view-invariants
Dec 16, 2022
Merged

Fix invariants optimization involving views (#7388)#7390
dyemanov merged 1 commit intomasterfrom
view-invariants

Conversation

@dyemanov
Copy link
Copy Markdown
Member

The idea is that we should not compare view field's stream with streams from other RSEs until the field has been expanded to the proper expression. Once it's done, sub->pass1() will recursively take care of the invariant checking. The test case from #7388 now shows good performance in both cases, but I'd like to have a second opinion.

@dyemanov dyemanov self-assigned this Nov 16, 2022
@livius2
Copy link
Copy Markdown

livius2 commented Nov 17, 2022

Is it possible to see difference of such execution in explain plan?
As now both plans are equal. Do you consider some extension to it?

@dyemanov
Copy link
Copy Markdown
Member Author

I agree it could be useful. Will take look at possible implementation.

@dyemanov
Copy link
Copy Markdown
Member Author

This is the suggested plan output:

Sub-query (invariant)
    -> Singularity Check
        -> Aggregate
            -> Nested Loop Join (outer)
                -> Filter
                    -> Hash Join (inner)
                        -> Table "RDB$RELATION_FIELDS" as "SUB RF" Full Scan
                        -> Record Buffer (record length: 529)
                            -> Table "RDB$RELATIONS" as "SUB R" Full Scan
                -> Filter
                    -> Table "RDB$SECURITY_CLASSES" as "SUB SC" Access By ID
                        -> Bitmap
                            -> Index "RDB$INDEX_7" Unique Scan
Select Expression
    -> Filter
        -> Nested Loop Join (outer)
            -> Nested Loop Join (inner)
                -> Filter
                    -> Table "RDB$RELATIONS" as "SUB R" Access By ID
                        -> Bitmap
                            -> Index "RDB$INDEX_1" Range Scan (full match)
                -> Filter
                    -> Table "RDB$RELATION_FIELDS" as "SUB RF" Access By ID
                        -> Bitmap
                            -> Index "RDB$INDEX_4" Range Scan (full match)
            -> Filter
                -> Table "RDB$SECURITY_CLASSES" as "SUB SC" Access By ID
                    -> Bitmap
                        -> Index "RDB$INDEX_7" Unique Scan

@livius2
Copy link
Copy Markdown

livius2 commented Nov 26, 2022

Will be good to see both plans in new version.
It will be now like this?

Sub-query (invariant)
    -> Singularity Check

and second version

Select Expression
    -> Singularity Check

or it will look differently?

Sub-query (invariant)
    -> Singularity Check

and second version

Sub-query (variant)
    -> Singularity Check

@dyemanov
Copy link
Copy Markdown
Member Author

"Select Expression" is the main query, it does not change. For sub-query now we see also "Select Expression", after the patch it will look as either "Sub-query" or "Sub-query (invariant)".

@dyemanov
Copy link
Copy Markdown
Member Author

Most sub-queries are correlated in practice, so reporting them as "variant" IMO is about to cause more questions than keeping is simple.

@livius2
Copy link
Copy Markdown

livius2 commented Nov 26, 2022

Yes, my concern was only if for variant there will be Select Expression or also Sub-query :)

@dyemanov
Copy link
Copy Markdown
Member Author

Plan explain improvements will be applied separately.

@dyemanov dyemanov deleted the view-invariants branch May 12, 2023 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants