Skip to content

create/drop table (with/without foreign key) take too long #47512

@kocoten1992

Description

@kocoten1992

Describe the problem

I've open #46869, but doesn't have concrete example, allowed me to recreate this with clear example and close the old one.

To Reproduce

root@:5432/defaultdb> CREATE DATABASE test_database;
CREATE DATABASE

Time: 78.922975ms
USE test_database;
SET

Time: 1.104456ms
root@:5432/test_database> CREATE TABLE buyers (
    id UUID PRIMARY KEY
);
CREATE TABLE

Time: 33.952167ms
root@:5432/test_database> CREATE TABLE cars (
    id UUID PRIMARY KEY,
    preferred_buyer_id UUID,
    CONSTRAINT cars_preferred_buyer_id_fkey FOREIGN KEY (preferred_buyer_id) REFERENCES buyers (id)
);
CREATE TABLE

Time: 6.709753419s
root@:5432/test_database> DROP TABLE cars CASCADE;
DROP TABLE

Time: 7.105337403s
root@:5432/test_database> DROP TABLE buyers CASCADE;
DROP TABLE

Time: 6.990172606s
use defaultdb;
root@:5432/defaultdb> drop database test_database;
DROP DATABASE

Time: 6.794767354s

Expected behavior
Some operation take almost 7s to run, something is wrong with:

  • create table with foreign key
  • drop table
  • drop database

There is no reason I'd need to wait 6s to create/drop (I'm using single-node-cluster, but even for real cluster, 7s would be too slow)

Environment:

  • CockroachDB version: master
  • Server OS: [e.g. Linux/Distrib]
  • Client app cockroach sql

Additional context
What was the impact? Unable integrate testing application with database

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityX-blathers-triagedblathers was able to find an owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions