cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

sql: operate to execute 'create index' takes too long

Open a6802739 opened this issue 10 years ago • 1 comments

my table schema is just like this,

[email protected]:26660> show columns from fc_word;
+-------------+-------------+-------+----------------+
|    Field    |    Type     | Null  |    Default     |
+-------------+-------------+-------+----------------+
| IdeaId      | INT         | true  | NULL           |
| UnitId      | INT         | true  | NULL           |
| PlanId      | INT         | true  | NULL           |
| UserId      | INT         | true  | NULL           |
| Iflag       | INT         | true  | NULL           |
| Ilong       | INT         | true  | NULL           |
| IdeaStat1   | INT         | true  | NULL           |
| IdeaStat2   | INT         | true  | NULL           |
| IdeaStat3   | INT         | true  | NULL           |
| IdeaStat4   | INT         | true  | NULL           |
| IdeaStat5   | INT         | true  | NULL           |
| IdeaStat6   | INT         | true  | NULL           |
| Touch       | INT         | true  | NULL           |
| ModUid      | INT         | true  | NULL           |
| ModTime     | TIMESTAMP   | true  | NULL           |
| Isdel       | INT         | true  | NULL           |
| ChkUid      | INT         | true  | NULL           |
| ChkTime     | TIMESTAMP   | true  | NULL           |
| RsnId       | INT         | true  | NULL           |
| Reason      | STRING(256) | true  | NULL           |
| DeviceOpt   | INT         | true  | NULL           |
| Temperature | INT         | true  | NULL           |
| rowid       | INT         | false | unique_rowid() |
+-------------+-------------+-------+----------------+

I insert into 80 millions row into this table.

then I execute a command create index USER_ID on fc_word(UserId). after 5 days, I can't see the index.

[email protected]:26660> show index from fc_word;
+---------+---------+--------+-----+--------+-----------+---------+
|  Table  |  Name   | Unique | Seq | Column | Direction | Storing |
+---------+---------+--------+-----+--------+-----------+---------+
| fc_word | primary | true   |   1 | rowid  | ASC       | false   |
+---------+---------+--------+-----+--------+-----------+---------+

so I execute the command again. It's just like this.

[email protected]:26660> create index USER_ID on fc_word(UserId);
pq: duplicate index name: "USER_ID"

I extract one node's runtime log here.

I160602 16:42:08.126347 storage/replica_command.go:1470  range 1134: new leader lease replica {1 4 4} 2016-06-02 08:42:07.69235094 +0000 UTC 1.680795161s following replica {3 12 1} 2016-06-02 08:41:59.730895034 +0000 UTC 7.961455906s [physicalTime=2016-06-02 08:42:08.126272966 +0000 UTC]
I160602 16:42:08.150334 storage/replica_command.go:1470  range 1241: new leader lease replica {1 4 4} 2016-06-02 08:42:07.720185325 +0000 UTC 1.67741721s following replica {2 8 1} 2016-06-02 08:41:59.764298364 +0000 UTC 7.955886961s [physicalTime=2016-06-02 08:42:08.150269245 +0000 UTC]
I160602 16:42:08.298791 storage/replica_command.go:1470  range 862: new leader lease replica {1 4 3} 2016-06-02 08:42:07.796922208 +0000 UTC 1.747722956s following replica {2 8 5} 2016-06-02 08:41:59.987894543 +0000 UTC 7.809027665s [physicalTime=2016-06-02 08:42:08.298710562 +0000 UTC]
I160602 16:42:10.100389 server/status/runtime.go:160  runtime stats: 27 GiB RSS, 320 goroutines, 810 MiB active, 8981.88cgo/sec, 0.26/0.06 %(u/s)time, 0.00 %gc (0x)
I160602 16:42:16.437153 storage/replica_command.go:1477  range 1134: replicaID 4 transfer raft leadership to replicaID 3
I160602 16:42:16.463351 storage/replica_command.go:1477  range 1241: replicaID 4 transfer raft leadership to replicaID 1
I160602 16:42:16.538237 storage/replica_command.go:1477  range 862: replicaID 3 transfer raft leadership to replicaID 5
I160602 16:42:18.544082 storage/replica_command.go:1470  range 1134: new leader lease replica {1 4 4} 2016-06-02 08:42:17.691128301 +0000 UTC 2.08548353s following replica {2 6 3} 2016-06-02 08:42:09.373146101 +0000 UTC 8.3179822s [physicalTime=2016-06-02 08:42:18.54401547 +0000 UTC]
I160602 16:42:18.792550 storage/replica_command.go:1470  range 1241: new leader lease replica {1 4 4} 2016-06-02 08:42:17.717438702 +0000 UTC 2.319684527s following replica {2 8 1} 2016-06-02 08:42:09.397602535 +0000 UTC 8.319836167s [physicalTime=2016-06-02 08:42:18.792473596 +0000 UTC]
I160602 16:42:19.075037 storage/replica_command.go:1470  range 862: new leader lease replica {1 4 3} 2016-06-02 08:42:17.792341434 +0000 UTC 2.530096205s following replica {2 8 5} 2016-06-02 08:42:09.544645164 +0000 UTC 8.24769627s [physicalTime=2016-06-02 08:42:19.074968652 +0000 UTC]

a6802739 avatar Jun 02 '16 08:06 a6802739

closing this issue because it is similar to #12424 . It is a lot better now, see the update to that bug.

vivekmenezes avatar Apr 06 '17 14:04 vivekmenezes