Skip to content

MDEV-39505: Diff in rows column of explain plan for delete table stmt#5063

Open
bsrikanth-mariadb wants to merge 1 commit into
bb-12.3-MDEV-39368-test-replayfrom
13.0-MDEV-39505-rows-diff-in-delete-table-plan
Open

MDEV-39505: Diff in rows column of explain plan for delete table stmt#5063
bsrikanth-mariadb wants to merge 1 commit into
bb-12.3-MDEV-39368-test-replayfrom
13.0-MDEV-39505-rows-diff-in-delete-table-plan

Conversation

@bsrikanth-mariadb
Copy link
Copy Markdown
Contributor

Although, number of rows for a table got recorded in the context, for a delete from table statement, but when replayed explain plan showed only 1 in the rows column.

There was no call being made to set_statistics_for_table() from delete_from_single_table() when all rows are deleted from a table.

Although, number of rows for a table got recorded in the context, for a
delete from table statement, but when replayed explain plan showed only
1 in the rows column.

There was no call being made to set_statistics_for_table() from
delete_from_single_table() when all rows are deleted from a table.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses MDEV-39505 by ensuring table statistics are correctly initialized in Sql_cmd_delete::delete_from_single_table before they are used to estimate deleted rows. It also adds a regression test and ensures the optimizer_replay_context is reset between test cases. A review comment points out that the new test case should use the default empty context name to correctly replay the recorded optimizer state and maintain test isolation.

--source "$MYSQLTEST_VARDIR/tmp/dump1.sql"
--enable_query_log
--enable_result_log
set optimizer_replay_context='opt_context';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The context name 'opt_context' used here appears to be carried over from the previous test case (see line 115, not shown in this diff). Since the current test records the context using set optimizer_record_context=1 at line 130 (which uses the default empty name), this command might be replaying the wrong context from a previous query instead of the DELETE query just recorded. To ensure test isolation and validity, please use the default name for both recording and replaying, or use a unique name for both.

set optimizer_replay_context='';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant