You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
r.table('tablename').delete.run can really be done in constant time by dropping and recreating the table (well, it isn't quite that simple because we need to maintain all the preferences for that table, but there's no reason for this query to be linear time either). (suggested by Damir)
One think i have noticed when doing a big delete job with many shards (10) is that it deleting from one range at a time not from from all shards at the same time.
Or you can speed it up a lot by dropping the table and recreating it (though you'll have to re-create your replication/sharding configuration and secondary indexes of course).
@danielmewes for a small table, dropping and recreating is actually slower. In our integration tests, we create one fake database per test thread, each with the same schema as the real thing.
Between test cases we delete all the data in all the tables (r.db(db_name).table_list().for_each(lambda table: r.db(db_name).table(table).delete()). This takes ~10ms (we've got about 20 tables) compared to around 20 seconds to drop and recreate all the tables and indexes.
Since we're doing this in tests, the tables never have too much data in them. We are still bottlenecked by those 10ms (with generative tests, we easily have 500 examples/test). So I'm all for the optimisation, but not if it makes it slower for the small table case!
Activity
wojons commentedon Nov 22, 2013
I have come across this issue also that most cases i just drop the table. is rethinkdb friendly about resusing old disk space?
coffeemug commentedon Nov 22, 2013
If you drop the table Rethink just deletes the file on the underlying file system. There shouldn't be any issues with doing it.
wojons commentedon Nov 22, 2013
Perfect :)
One think i have noticed when doing a big delete job with many shards (10) is that it deleting from one range at a time not from from all shards at the same time.
karlgrz commentedon Aug 9, 2016
I just tried running the following query on a table with approximately 5 million records:
It timed out. Am I correct that this is the expected behavior? Or should this be a fast operation?
Cluster topology: 3 nodes, this table only replicated onto a single node without sharding.
danielmewes commentedon Aug 9, 2016
@karlgrz This is still expected behavior today. You can somewhat speed it up, by doing
Or you can speed it up a lot by dropping the table and recreating it (though you'll have to re-create your replication/sharding configuration and secondary indexes of course).
karlgrz commentedon Aug 9, 2016
@danielmewes that's what I figured. Thanks for the drop / recreate suggestion. That will probably be perfectly fine in this situation. 👍
thomasmodeneis commentedon Oct 30, 2016
@danielmewes would be nice to add this to documentation!
cristicbz commentedon May 19, 2019
@danielmewes for a small table, dropping and recreating is actually slower. In our integration tests, we create one fake database per test thread, each with the same schema as the real thing.
Between test cases we delete all the data in all the tables (
r.db(db_name).table_list().for_each(lambda table: r.db(db_name).table(table).delete()). This takes ~10ms (we've got about 20 tables) compared to around 20 seconds to drop and recreate all the tables and indexes.Since we're doing this in tests, the tables never have too much data in them. We are still bottlenecked by those 10ms (with generative tests, we easily have 500 examples/test). So I'm all for the optimisation, but not if it makes it slower for the small table case!
board: tick rethinkdb#134 — light audit; guard PASS, CI 3-green, stor…