Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invariants optimization involving views (#7388) #7390

Merged
merged 1 commit into from Dec 16, 2022
Merged

Conversation

dyemanov
Copy link
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

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
Member Author

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

@dyemanov
Copy link
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

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
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
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

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
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.

None yet

2 participants