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

Stick to outdated stats rather than pseudo stats #27601

Closed
dbsid opened this issue Aug 26, 2021 · 0 comments · Fixed by #28554
Closed

Stick to outdated stats rather than pseudo stats #27601

dbsid opened this issue Aug 26, 2021 · 0 comments · Fixed by #28554
Assignees
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@dbsid
Copy link
Contributor

dbsid commented Aug 26, 2021

Enhancement

A recent issue for reference, I was running tpc-c workload intensively. As the workload on-going and the auto analyze job failed due to "gc life time is shorter than transaction duration". the statistics did not got updated, then the statistics become outdated, the optimizer switch to pseudo stats and cause plan change.

This behavior assume that the pseudo stats is better than the outdated stats. This is not true.

I would suggest the optimizer sticked to the gathered stats, even it's outdated, to prevent plan change.

// getStatsTable gets statistics information for a table specified by "tableID".
// A pseudo statistics table is returned in any of the following scenario:
// 1. tidb-server started and statistics handle has not been initialized.
// 2. table row count from statistics is zero.
// 3. statistics is outdated.
func getStatsTable(ctx sessionctx.Context, tblInfo *model.TableInfo, pid int64) *statistics.Table {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants