i asked about foreign keys with cascase delete some time ago.
so with 2.0 i am revisiting this topic. here is my table schema:
CREATE TABLE alternateParent
( id INT PRIMARY KEY
, alternateParent_value VARCHAR(50) NOT NULL
);CREATE TABLE grandParentTable
( id INT PRIMARY KEY
, grandParentTable_name VARCHAR(50) NOT NULL
);CREATE TABLE parentTable
( id INT PRIMARY KEY
, grandParentTable INT NOT NULL REFERENCES grandParentTable(id) ON DELETE CASCADE ON UPDATE CASCADE
, parentTable_name VARCHAR(500) NOT NULL
, INDEX (grandParentTable)
);CREATE TABLE childTable
( id INT PRIMARY KEY
, parentTable INT NOT NULL REFERENCES parentTable (id) ON DELETE CASCADE ON UPDATE CASCADE
, alternateParent INT NOT NULL REFERENCES alternateParent (id) ON DELETE CASCADE ON UPDATE CASCADE
, childTable_name VARCHAR(500) NOT NULL
, INDEX (parentTable )
, index (alternateParent)
);
each table has 10 more rows than the one “above” it, so the lowest table (childTable) has 1000 rows.
so grandparent has 10, parent has 100, and child has 1000.
here is my query:
SELECT count(*)
FROM grandParentTable, parentTable, alternateParent, childTable
WHERE 1=1
AND (alternateParent.id = childtable.alternateParent )
AND (parenttable.id = childtable.parenttable)
AND (grandParentTable.id = parentTable.grandParentTable)
AND (parentTable.id = 5)
my initial results are “bat outta hell” speeds, compared to earlier versions of cockroachDB.
my question: is this a “fair” test to test a grandparent-parent-child relationship? these speeds appear to blow mysql out of the water.
assuming this is a fair test, congratulations on such a successful release!
and yes, CASCADE DELETE is working wonderfully too.