-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: add primary key on empty table very slow #47607
Copy link
Copy link
Closed
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityOriginated from the communityX-blathers-triagedblathers was able to find an ownerblathers was able to find an owner
Description
Describe the problem
discover while trying reproduce #47512
To Reproduce
- start fresh
cockroach start-single-node --insecure(empty data) - create a file
create_users_table.sqlwith content follow
drop table if exists "users" cascade;
create table "users" ("id" uuid not null, "name" varchar(255) not null, "email" varchar(255) not null, "password" varchar(255) not null, "remember_token" varchar(100) null, "created_at" timestamp(0) without time zone null, "updated_at" timestamp(0) without time zone null, "deleted_at" timestamp(0) without time zone null);
alter table "users" add primary key ("id");
alter table "users" add constraint "users_email_unique" unique ("email");- run
cockroach sql --insecure < create_users_table.sql
It take a whooping 30s to add primary key on empty table (╯°□°)╯︵ ┻━┻
NOTICE: primary key changes are finalized asynchronously; further schema changes on this table may be restricted until the job completes
ALTER TABLE
Time: 211.001799ms
ALTER TABLE
Time: 30.581253037s
Expected behavior
Should be much faster since the table is empty.
Environment:
- CockroachDB version
Build Tag: 82294d1
Build Time: 2020/04/15 01:47:13
Distribution: CCL
Platform: linux amd64 (x86_64-pc-linux-gnu)
Go Version: go1.13.9
C Compiler: 4.2.1 Compatible Clang 3.8.0 (tags/RELEASE_380/final)
Build SHA-1: 82294d100ad1cb26b488f53e7241242d474d58d7
Build Type: development
- Server OS: ubuntu 20.04 dev
- Client app
cockroach sql(same version as server)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityOriginated from the communityX-blathers-triagedblathers was able to find an ownerblathers was able to find an owner