-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
sql: optimize DROP and TRUNCATE #2003
Comments
I was thinking about this as well, though it is obviously lower priority than getting various bits of functionality working first. It would be great if we could figure out how to perform the deletion as part of normal compactions. |
We don't have priorities, or I would have put it as "get around to it when someone's bored". |
We can make our own priority labels. |
so the idea here is to make data deletion asynchronous? There's probably value in not making it too asynchronous. If I drop a table, I'd at the very least want the storage stats to update quickly, and to do that you might as well delete it all as soon as you can. |
We haven't started doing accounting for structured data, but we'll probably need per-table and per-database stats, so we'll need some logic for aggregation. |
related to |
This commit doesn't fix cockroachdb#2003: chunk table TRUNCATE
Implementing Truncate, one thought is to use a new table ID and delete all the keys from the old table ID. Unfortunately that's complicated by the fact that we have cross table references from foreign keys and interleaved tables that use the table ID as the reference, and we would also need to update those. I think it's best to just disable the table from reads/writes, truncate it and reenable it. I'll try that option for now. |
The DROP TABLE is deemed complete as soon as the table name is no longer in use. The table data GC cleanup is executed asynchronously through the asynchronous schema change path, and can be made more performant later. fixes cockroachdb#14279 related to cockroachdb#2003
In this change TRUNCATE is executed by swapping the ID of a table. The old id is dropped and a new id is created for the table. The old table descriptor is gc-ed through the asynchronous schema changer. fixed cockroachdb#2003
The DROP TABLE is deemed complete as soon as the table name is no longer in use. The table data is deleted asynchronously through the asynchronous schema change path, and can be made more performant later. fixes cockroachdb#14279 related to cockroachdb#2003
In this change TRUNCATE is executed by swapping the table ID. The old id is dropped and a new id is created for the table. The old table descriptor is deleted through the asynchronous schema changer. Note: with this change TRUNCATE is no longer transactional. The TRUNCATE itself is implemented in a transaction, but the name -> old id map could be present on a node after the transaction resulting in data being added using the old id. The newly inserted data using the old mapping will eventually be deleted. fixed cockroachdb#2003
TRUNCATE
currently deletes all rows in the table before returning, andDROP
just callsTRUNCATE
followed by table descriptor deletions.Instead, we should introduce a
deleted
field for tables causing the following:DROP
would just mark the table as deleted, remove the name -> ID entry and exit.TRUNCATE
would callDROP
and create a new table with the same name.The text was updated successfully, but these errors were encountered: