Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

global index limitation: Unsupported Global Index including all columns in the partitioning expression #56230

Closed
dbsid opened this issue Sep 23, 2024 · 1 comment · Fixed by #56868
Assignees
Labels
component/tablepartition This issue is related to Table Partition of TiDB. sig/sql-infra SIG: SQL Infra type/enhancement The issue or PR belongs to an enhancement.

Comments

@dbsid
Copy link
Contributor

dbsid commented Sep 23, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

We are encountering hotspots on both the AUTO_INCREMENT primary key and the updated_at index during ingestion. To address this, I plan to implement hash/key partitioning to alleviate the hotspots on both the primary key and the secondary index (idx_updated_at). The specific actions I intend to take are:

  1. Keep the primary key and idx_updated_at as local indexes to distribute load and mitigate the hotspots.
  2. Convert the index on user_id (idx_user_id) into a global index. Since user_id is not unique, I will modify the index by including the id column, ensuring idx_user_id becomes a unique index.
# original schema
CREATE table t (
  id bigint NOT NULL AUTO_INCREMENT,
  updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  user_id bigint DEFAULT NULL,
  PRIMARY KEY (id),
  KEY idx_user_id (user_id, id),
  KEY idx_updated_at (updated_at)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

set session tidb_enable_global_index=on;

CREATE table t (
  id bigint NOT NULL AUTO_INCREMENT,
  updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  user_id bigint DEFAULT NULL,
  PRIMARY KEY (id),
  UNIQUE KEY idx_user_id (user_id, id) global,
  KEY idx_updated_at (updated_at)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITION BY KEY(id)
PARTITIONS 64;

2. What did you expect to see? (Required)

no error

3. What did you see instead (Required)

mysql> CREATE table t (
    ->   id bigint NOT NULL AUTO_INCREMENT,
    ->   updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    ->   user_id bigint DEFAULT NULL,
    ->   PRIMARY KEY (id),
    ->   UNIQUE KEY idx_user_id (user_id, id) global,
    ->   KEY idx_updated_at (updated_at)
    -> ) ENGINE=InnoDB DEFAULT CHARSET=latin1
    -> PARTITION BY KEY(id)
    -> PARTITIONS 64;
ERROR 8200 (HY000): Unsupported Global Index including all columns in the partitioning expression

4. What is your TiDB version? (Required)

v8.3.0

@dbsid dbsid added the type/bug The issue is confirmed as a bug. label Sep 23, 2024
@dbsid
Copy link
Contributor Author

dbsid commented Sep 23, 2024

/assign @mjonss

@dbsid dbsid changed the title global index limitation: unable to create global index with key partition on primary key column global index limitation: Unsupported Global Index including all columns in the partitioning expression Sep 23, 2024
@Defined2014 Defined2014 added type/enhancement The issue or PR belongs to an enhancement. component/tablepartition This issue is related to Table Partition of TiDB. sig/sql-infra SIG: SQL Infra and removed type/bug The issue is confirmed as a bug. labels Sep 24, 2024
@Defined2014 Defined2014 self-assigned this Oct 23, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
component/tablepartition This issue is related to Table Partition of TiDB. sig/sql-infra SIG: SQL Infra 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