-
Notifications
You must be signed in to change notification settings - Fork 107
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
Regression with Parallel hints combined with removal of indexes in Index hints #164
Comments
Thanks for the report @michaelpq After we spoke offline, I spent time looking further into this. What I observed is the follows:
I have a repro of the test case mentioned in the thread.
Here is where things get interesting. If only the Parallel hints are supplied, no parallel hint is enforced.
I can force the parallel plan by keeping only index scans enabled. But, notice it's not a Parallel Seq scan on "b", but rather a Parallel Index Scan.
It is clear that parallel enforcement, including the "hard" option, is not showing the expected results even in 1.4.1 thoughts? Regards, Sami |
With the above said, I do agree to revert the patch on stable branches, since the existing behavior, while not great, is what the users expect. |
Yeah. The fact that we would completely discard the Parallel hints when mixing more than one table sounds strange to me. At this stage, I think that we'd better document all that in the shape of tests where one could look at a regression.diffs to see the difference generated when tweaking the code, or development is not going to scale well. I'm OK if we add comments like "strangely, this ignores both Parallel hints, perhaps these should be pushed under two Gather nodes". Or stuff like that. I'll go put the stable branches in their previous stable with a revert, as I doubt that we've appreciated all the plan manipulations possible yet. Changing that in a major release is less or an issue to me. At this stage I'd rather prioritize plan stability to not impact users across these minor updated. |
I agree. I'll submit a patch for Parallel Hint tests ( including those mentioned above ). |
This reverts commit a3646e1, that we have found to do more weird plan manipulations by ignoring in some cases Parallel hints when they should not. The behavior before this commit has also some historical weirdness, but impacting the stability of plans is not a good idea in stable branches, so for now this change is reverted. Additional regression tests will be added on HEAD to track all the behaviors around parallel hints that have been seen, while keeping the new plan changes only for 17~ and new major release integration. Per discussion on #164. Backpatch-through: 13
This reverts commit a3646e1, that we have found to do more weird plan manipulations by ignoring in some cases Parallel hints when they should not. The behavior before this commit has also some historical weirdness, but impacting the stability of plans is not a good idea in stable branches, so for now this change is reverted. Additional regression tests will be added on HEAD to track all the behaviors around parallel hints that have been seen, while keeping the new plan changes only for 17~ and new major release integration. Per discussion on #164. Backpatch-through: 13
This reverts commit a3646e1, that we have found to do more weird plan manipulations by ignoring in some cases Parallel hints when they should not. The behavior before this commit has also some historical weirdness, but impacting the stability of plans is not a good idea in stable branches, so for now this change is reverted. Additional regression tests will be added on HEAD to track all the behaviors around parallel hints that have been seen, while keeping the new plan changes only for 17~ and new major release integration. Per discussion on #164. Backpatch-through: 13
This reverts commit a3646e1, that we have found to do more weird plan manipulations by ignoring in some cases Parallel hints when they should not. The behavior before this commit has also some historical weirdness, but impacting the stability of plans is not a good idea in stable branches, so for now this change is reverted. Additional regression tests will be added on HEAD to track all the behaviors around parallel hints that have been seen, while keeping the new plan changes only for 17~ and new major release integration. Per discussion on #164. Backpatch-through: 13
Attached are tests that cover several of the gaps discovered in this discussion: 1/ Ensure that Parallel enforcement does not break when a non-existent index is used in an IndexScan hint. |
Thanks for the patch. The patch you are proposing for the additional tests has no explanation about what's being done, like the interactions between the non-existing indexes and the hints. It may be good to document now with some big XXX that some of these plans are weird because of YYY. I am not sure that it is a good idea to use and empty the existing tables t5 and t6 for these new tests. Perhaps splitting that into a new file would make more sense? |
I hesitated doing that as it's not the norm to add much documentation to the tests, but that is not a good reason not to. I will add a better description.
I am creating new tables for these tests in the sql/ut-init.sql file. I did not think it was worth adding a new init and test files for these few tests.
|
After second thought, showing that the non-existing index does not prevent parallel hint enforcement is not necessary. So, the test now shows the important part. For empty tables, parallel hints can only be enforced on index scans and not sequential scans. Attached is the revised test. Regards, |
a3646e1 still exists on HEAD and now PG17. Now is the time to do a re-evaluation of what has been committed, knowing the reasons why the patch had to be backed out of past stable branches. |
Looking at the discussion above, 684986a exposed pre-existing odd behavior with parallel enforcement. Especially, if there are no rows in a table, parallel sequential scans cannot be enforced. This scenario is covered by the suggested test case [1]. Do you think there is value in these test? In the case mentioned at the top of the thread, 1.4.1 is able to perform a parallel sequential scan on an empty table by "accident". Because an IndexScan hint is used on
I think 684986a is a good improvement and I am not sure if the pre-existing behavior is the behavior that we want to maintain for the next major version release. |
As a result of the discussion with Sami Imseih, this commit adds tests showing that for empty tables, only parallel index scans can be enforced and not sequential scans. This is an old, historical, rather weird behavior, that may not be worth changing in the long run as empry tables are not something users rely a lot when using pg_hint_plan, but let's add a test tracking if any future change impacts the plans generated. Author: Sami Imseih Backpatch-through: 17 Per discussion on issue #164.
As a result of the discussion with Sami Imseih, this commit adds tests showing that for empty tables, only parallel index scans can be enforced and not sequential scans. This is an old, historical, rather weird behavior, that may not be worth changing in the long run as empry tables are not something users rely a lot when using pg_hint_plan, but let's add a test tracking if any future change impacts the plans generated. Author: Sami Imseih Backpatch-through: 17 Per discussion on issue #164.
I'm sold to it. It's really a weird behavior, THB, but we've had that for a long time and nobody has complained about it, either. There is a good argument for changing that in the long run, perhaps, and make sure that the workers triggered work the same way without the need for the NoSeqScan hints. In any case, such a test will be able to track if the behavior changes. I've done that with e92d75f, and now let's close this issue.
I'm OK to treat that as a new feature in PG17. We'll see based on the feedback, and impacting plans after a major version upgrade stresses me less than for a minor upgrade. Postgres itself has breakages every year after its majors. |
A user has reported a regression in the latest release series regarding subject, related to commit 684986a (applies to all stable branches). Imagine two simple tables:
Now here is an exotic case:
Under 1.4.1, we are getting this plan:
I think that this is not correct, for two reasons:
Now, under 1.4.2, we get this plan:
This is better in the fact that IndexScan(b bookings_tmp_not_exist) is marked as unused. Still, this is worse in the fact that the Parallel hint with the number of workers gets entirely ignored, leading to a regression.
I've been considering a couple of options about what to tweak in the case where an index restriction is applied, but my mind comes down to a few conclusions:
The text was updated successfully, but these errors were encountered: