pkg/statistics/handle/autoanalyze/priorityqueue/calculatoranalysis/README.md
This test suite evaluates the effectiveness of the auto-analyze priority calculator for database statistics. The calculator prioritizes which tables should be analyzed based on factors such as table size, data changes, and time since last analysis.
Data Generation: The test generates diverse scenarios using combinations of:
Priority Calculation: For each scenario, the priority calculator computes a weight based on:
Realistic Constraints: The test data is generated with realistic constraints:
generateTestData() creates test scenarios directly in memory.TestPriorityCalculatorWithGeneratedData() is the main test function that:
generateTestData()PriorityCalculatorcalculated_priorities.golden.csvcalculator_analysis_test.go: Contains the main test logic and data generationcalculated_priorities.golden.csv: Expected output with calculated priorities for all scenariosTo run the test:
go test -v ./pkg/statistics/handle/autoanalyze/priorityqueue/calculatoranalysis
If you want to update the golden file, run the test with -update flag:
go test -v ./pkg/statistics/handle/autoanalyze/priorityqueue/calculatoranalysis -update
The test compares the generated priorities against the golden file calculated_priorities.golden.csv with
This output allows for analysis of how the priority calculator behaves across different scenarios.
This test helps ensure that the priority calculator provides consistent and predictable behavior in the auto-analyze feature across a wide range of realistic scenarios.