pingcap / pingcap/tidb

Improve Analyze Time Window Behavior

Open
#62,009 1 comment 0 reactions 0 assignees View on GitHub
component/statistics sig/planner type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Background
Currently, some large tables cannot be analyzed within the configured time window and their analyze processes get killed. This leads to missing statistics for these tables, which can negatively impact query performance.

## Current Behavior
- When analyze operations exceed the configured time window, they are terminated
- This results in incomplete statistics collection for large tables
- Missing statistics can lead to suboptimal query plans

## Proposed Changes
1. **Within Time Window**:
- Maximize resources for statistics collection
- Utilize normal scan concurrency during this period

2. **Outside Time Window**:
- Continue collection with minimal resources instead of killing the process
- Use reduced resources to minimize impact on user workloads while still collecting needed statistics

3. **New Control Variable**:
- Add a configuration option that allows users to:
- Fall back to old behavior (no collection outside window) if needed
- Maintain backward compatibility for upgrading clusters

## Benefits
- Ensures statistics are collected for all tables, regardless of size
- Respects user's intention to limit resource usage during busy periods
- Provides backward compatibility and control for users who prefer the old behavior

## Implementation Considerations
- Default behavior for time window = 24 hours should remain unchanged
- When time window is explicitly set, new behavior will apply
- Need to determine appropriate resource limits for outside-window collection

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.