pingcap / pingcap/tidb

it's hard to locate a user explicit value down to a decided encoded bound among buckets

Open
#49,675 0 comments 0 reactions 0 assignees View on GitHub
sig/planner type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement
```
MySQL [dore_ddps]> show stats_buckets where column_name='IDX_BS_PCFB_CHARGE_BOOK_4';
+-----------+---------------------+----------------+---------------------------+----------+-----------+--------+---------+-------------------------------+-------------------------------+------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Bucket_id | Count | Repeats | Lower_Bound | Upper_Bound | Ndv |
+-----------+---------------------+----------------+---------------------------+----------+-----------+--------+---------+-------------------------------+-------------------------------+------+
| dore_ddps | BS_PCFB_CHARGE_BOOK | | IDX_BS_PCFB_CHARGE_BOOK_4 | 1 | 0 | 765 | 40 | 10001003� �0780 � | 10001003� �0980 � | 0 |
| dore_ddps | BS_PCFB_CHARGE_BOOK | | IDX_BS_PCFB_CHARGE_BOOK_4 | 1 | 1 | 1658 | 382 | 10001003� �5092 � | 10001003� �7481 � | 0 |
| dore_ddps | BS_PCFB_CHARGE_BOOK | | IDX_BS_PCFB_CHARGE_BOOK_4 | 1 | 2 | 2423 | 40 | 10001003� �7501 � | 10001003� �7550 � | 0 |
| dore_ddps | BS_PCFB_CHARGE_BOOK | | IDX_BS_PCFB_CHARGE_BOOK_4 | 1 | 3 | 3188 | 255 | 10001003� �7560 � | 10001003� �7641 � | 0 |
| dore_ddps | BS_PCFB_CHARGE_BOOK | | IDX_BS_PCFB_CHARGE_BOOK_4 | 1 | 4 | 3953 | 382 | 10001003� �7670 � | 10001003� �7721 � | 0 |
| dore_ddps | BS_PCFB_CHARGE_BOOK | | IDX_BS_PCFB_CHARGE_BOOK_4 | 1 | 5 | 4718 | 40 | 10001003� �7750 � | 10001003� �7841 � | 0 |
| dore_ddps | BS_PCFB_CHARGE_BOOK | | IDX_BS_PCFB_CHARGE_BOOK_4 | 1 | 6 | 5484 | 255 | 10001003� �7891 � | 10001003� �8693 � | 0 |
| dore_ddps | BS_PCFB_CHARGE_BOOK | | IDX_BS_PCFB_CHARGE_BOOK_4 | 1 | 7 | 6249 | 40 | 10001003� �8932 � | 10001005� �0602 � | 0 |
| dore_ddps | BS_PCFB_CHARGE_BOOK | | IDX_BS_PCFB_CHARGE_BOOK_4 | 1 | 8 | 7014 | 255 | 10001005� �0790 � | 10001005� �0901 � | 0 |
```

since KEY `IDX_BS_PCFB_CHARGE_BOOK_4` (`CHARGE_DT`,`FEE_CLASS_CD`,`CHARGE_ORG_NO`), once we have CHANGE_DT which is a DATE type with value '2023-12-14 00:00:00', how can we easily locate its bucket it belongs to from the index prefix column.

* maybe add value option in where clause.
* maybe we can add more stats detail out when exec this query

Contributor guide

Open the contributing guide

Research direction

The issue provides no source files or tests; start by examining the SHOW STATS_BUCKETS query and its bucket output for the IDX_BS_PCFB_CHARGE_BOOK_4 index. Define the desired behavior for locating a DATE value through an index-prefix column, including whether this requires a WHERE-clause value option or additional statistics detail.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.