fix(seekdb): Fixed NULL opt_stat_manager handling on Windows in OptTableMeta::init_column_meta. Added #ifdef _WIN32 fallback.#888
Open
ep-12221 wants to merge 2 commits into
Open
Conversation
…stats Two-part fix for Windows where opt_stat_manager is unavailable 1. In ObJoinOrder::get_used_stat_partitions: When opt_stat_manager is NULL on Windows, set get_stat=true to skip stat retrieval and return success instead of OB_ERR_UNEXPECTED. This prevents the caller from aborting before add_base_table_meta_info populates basic_table_metas. 2. In OptTableMeta::init_column_meta: When opt_stat_manager or session_info is NULL on Windows, populate column metadata with defaults via set_default_meta instead of returning OB_ERR_UNEXPECTED. Root cause: On Windows, NULL opt_stat_manager caused an error cascade get_used_stat_partitions returns error -> basic_table_metas stays empty -> get_column_basic_from_meta can't find column metadata -> falls through to get_var_basic_default which sets ndv=1.0 -> join selectivity ~0.98 -> EST.ROWS=9 (3*3*0.98) instead of correct value. DIMA: 2026042800115792720 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When update_table_meta_info copies table meta entries from basic_table_metas_ to update_table_metas_ via copy_table_meta_info it uses push_back which can create multiple entries for the same table_id with different row counts (e.g. rows=1 from default stats rows=3 from storage estimation). The original get_table_meta_by_table_id returned only the first matching entry, which could be a stale entry with rows_=1 leading to ndv=1, join selectivity=1.0, and inflated EXPLAIN EST.ROWS. Fix by iterating all entries and returning the one with the highest row count, ensuring join selectivity uses the most accurate estimate. Fixes DIMA bug: 2026042800115792720 (EXPLAIN JOIN EST.ROWS=9 instead of 3 on multi-part PK tables) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
Contributor
Author
|
Not fixed, the issue still occurs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task Description
Fixed a bug in the optimizer's selectivity estimation on Windows where a NULL
opt_stat_managerwould cause column metadata initialization to fail, leading to uninitializedcolumn_id_values. This resulted in incorrect join cardinality estimates (e.g., EST.ROWS=9 instead of the expected EST.ROWS=5).Solution Description
In
OptTableMeta::init_column_meta(src/sql/optimizer/ob_opt_selectivity.cpp:444-446), whenget_opt_stat_managerreturns NULL on Windows (statistics module not initialized), the code previously setret = OB_ERR_UNEXPECTEDand returned early. This skipped the subsequentrefine_column_metaloop (lines 485-489) that sets thecolumn_idfor each metadata entry.The fix adds a
#ifdef _WIN32fallback for the NULL manager check, making it consistent with the existing Windows fallback path forbatch_get_column_statsfailure (lines 456-466). This ensures therefine_column_metaloop executes, properly initializing thecolumn_metas_array.Passed Regressions
Local build was not performed due to the time required for a full Windows cmake configuration and compilation. The fix is in pure C++ logic within the optimizer's selectivity estimation layer and has no runtime dependencies. The change will be validated by Farm CI tests against
sfu.for_update_multi_part_skip_locked.Upgrade Compatibility
Other Information
DIMA: 2026042800115792720
Release Note
Fixed incorrect join cardinality estimation on Windows when the optimizer statistics manager is not initialized.