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

add index slowly when the PK generation strategy is snowflake #5820

Closed
kitdine opened this issue Feb 8, 2018 · 4 comments
Closed

add index slowly when the PK generation strategy is snowflake #5820

kitdine opened this issue Feb 8, 2018 · 4 comments
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@kitdine
Copy link

kitdine commented Feb 8, 2018

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
  • in this test case , just a table about 5000w rows, and generate Pk with snowflake which the PK is not continuously;

  • the table schema:

CREATE TABLE `test_table` (
  `id` bigint(20) NOT NULL COMMENT '主键',
  `request_url` varchar(100) NOT NULL COMMENT '请求URL',
  `scheme` varchar(10) NOT NULL COMMENT '协议',
  `cost_time` bigint(18) NOT NULL COMMENT '耗时',
  `query_string` varchar(500) NOT NULL DEFAULT 'query_string' COMMENT '请求信息',
  `headers` json NOT NULL COMMENT '头信息',
  `parameters` json NOT NULL COMMENT '参数',
  `cookie` json NOT NULL COMMENT 'cookie',
  `path_info` varchar(100) NOT NULL DEFAULT 'path_info' COMMENT 'path_info',
  `CLIENT_VERSION` varchar(8) GENERATED ALWAYS AS (json_extract(`headers`, "$.CLIENT_VERSION")) VIRTUAL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_http_playback_request_url` (`request_url`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8mb4_general_ci;
  • create index:
alter table test_table add index index_virual_client_version(CLIENT_VERSION);
  1. What did you expect to see?
  • Complete within a receiveable time,maybe a couple of hours.
  1. What did you see instead?
  • use admin show ddl,shows:
schema_ver owner job self_id
667 b9bdb1f7-03ba-4d13-a463-aa408681379d ID:1264, Type:add index, State:running, SchemaState:write reorganization, SchemaID:1251, TableID:1261, RowCount:6580689, ArgLen:0, start time: 2018-02-06 20:45:00.128 +0800 CST b9bdb1f7-03ba-4d13-a463-aa408681379d
  • just adding 20w rows in one hour
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
Release Version: v1.1.0-alpha.1-65-g8cc9e45
Git Commit Hash: 8cc9e45f419aba64c4ff63f676f66a948711525d
Git Commit Branch: master
UTC Build Time:  2018-02-05 02:55:59
GoVersion:  go version go1.9.2 linux/amd64
@alivxxx
Copy link
Contributor

alivxxx commented Feb 8, 2018

Thanks for your feedback!
PTAL @zimulala

@alivxxx
Copy link
Contributor

alivxxx commented Feb 8, 2018

We will speed up the operation of adding index, see #5192.

@ngaut ngaut added the type/enhancement The issue or PR belongs to an enhancement. label Feb 11, 2018
@shenli shenli added the DDL label Feb 13, 2018
@winkyao
Copy link
Contributor

winkyao commented Mar 22, 2018

@kitdine This issue was fixed by PR: #5964 , you can try the newest master branch. Appreciate to get your feedback :)

@kitdine
Copy link
Author

kitdine commented Mar 23, 2018

good to hear that,I will test it ASAP
@winkyao amazing! 4000w+ rows Reduced the cost time from two weeks to two hours

@kitdine kitdine closed this as completed Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

5 participants