MDEV-39942: use actual_rec_per_key in loose scan sj optimization#5284
MDEV-39942: use actual_rec_per_key in loose scan sj optimization#5284bsrikanth-mariadb wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates Loose_scan_opt in sql/opt_subselect.h to call actual_rec_per_key() instead of directly accessing the rec_per_key array. The reviewer pointed out a potential precision loss issue because the returned floating-point value is assigned to a ulong variable (rpc), which can lead to inaccurate optimizer estimations. A refactoring was suggested to use a double type and avoid assignment inside the conditional statement.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
5d44415 to
6ffa772
Compare
While performing loose scan semi-join optimization in Loose_scan_opt::check_ref_access_part1() [opt_subselect.h], the filtered value in the explain plan was in-consistent for a table with index when same data was inserted using "insert into t1 values()...", and "insert into t1 select * from t2". This is noticed when rec_per_key[] was used to get the number of records during optimization. However, when actual_rec_per_key() is used to get the number of records, we don't notice this discrepancy. This PR changes the rec_per_key[] usage to actual_rec_per_key() in the method Loose_scan_opt::check_ref_access_part1() [opt_subselect.h]
6ffa772 to
f17beec
Compare
While performing loose scan semi-join optimization in
Loose_scan_opt::check_ref_access_part1() [opt_subselect.h],
the filtered value in the explain plan was in-consistent for a table
with index when same data was inserted using "insert into t1 values()...",
and "insert into t1 select * from t2". This is noticed when
rec_per_key[] was used to get the number of records during optimization.
However, when actual_rec_per_key() is used to get the number of records,
we don't notice this discrepancy.
This PR changes the rec_per_key[] usage to actual_rec_per_key() in the
method Loose_scan_opt::check_ref_access_part1() [opt_subselect.h]