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

incorrect correlation of histogram when column is loaded ad hoc #9700

Closed
eurekaka opened this issue Mar 13, 2019 · 0 comments
Closed

incorrect correlation of histogram when column is loaded ad hoc #9700

eurekaka opened this issue Mar 13, 2019 · 0 comments
Assignees
Labels
component/statistics type/bug The issue is confirmed as a bug.

Comments

@eurekaka
Copy link
Contributor

eurekaka commented Mar 13, 2019

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
mysql> create table t(c int);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t values(1),(2),(3),(4),(5);
Query OK, 5 rows affected (0.01 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql> analyze table t;
Query OK, 0 rows affected (0.01 sec)

mysql> show stats_histograms where table_name = 't';
Empty set (0.00 sec)

-- reboot TiDB server and use a new connection

mysql> show stats_histograms where table_name = 't';
Empty set (0.00 sec)

-- use this query to mark column histogram as needed
mysql> explain select * from t where c = 1;
+---------------------+-------+------+----------------------------------------------+
| id                  | count | task | operator info                                |
+---------------------+-------+------+----------------------------------------------+
| TableReader_7       | 0.01  | root | data:Selection_6                             |
| └─Selection_6       | 0.01  | cop  | eq(test.t.c, 1)                              |
|   └─TableScan_5     | 10.00 | cop  | table:t, range:[-inf,+inf], keep order:false |
+---------------------+-------+------+----------------------------------------------+
3 rows in set (0.00 sec)

mysql> show stats_histograms where table_name = 't';
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time         | Distinct_count | Null_count | Avg_col_size | Correlation |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
| test    | t          |                | c           |        0 | 2019-03-13 18:14:55 |              5 |          0 |            8 |           0 |
+---------+------------+----------------+-------------+----------+---------------------+----------------+------------+--------------+-------------+
1 row in set (0.00 sec)
  1. What did you expect to see?

Correlation field should be 1.

  1. What did you see instead?

Correlation field is 0.

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
Release Version: v3.0.0-beta-211-g09beefbe0
Git Commit Hash: 09beefbe045011e3c77608c9ed33da87c11efa94
Git Branch: master
UTC Build Time: 2019-03-13 10:13:24
GoVersion: go version go1.12 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/statistics type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

1 participant