satellite/metabase: use TRUNCATE in TestingDeleteAll

TRUNCATE is faster than DELETE when deleting all rows.

As almost every metabase test case calls TestingDeleteAll, this change
should give some slight test speed-up.

Change-Id: Ib477962b6deb93edd60d6db2f1be6ede1b4b2381
This commit is contained in:
Kaloyan Raev 2022-05-10 18:33:09 +03:00 committed by Michal Niewrzal
parent a8b1e1a81d
commit 15bed0ed0e

View File

@ -107,10 +107,7 @@ func (db *DB) TestingGetState(ctx context.Context) (_ *RawState, err error) {
// TestingDeleteAll deletes all objects and segments from the database. // TestingDeleteAll deletes all objects and segments from the database.
func (db *DB) TestingDeleteAll(ctx context.Context) (err error) { func (db *DB) TestingDeleteAll(ctx context.Context) (err error) {
_, err = db.db.ExecContext(ctx, ` _, err = db.db.ExecContext(ctx, `
DELETE FROM objects; TRUNCATE objects, segments, segment_copies, node_aliases;
DELETE FROM segments;
DELETE FROM segment_copies;
DELETE FROM node_aliases;
SELECT setval('node_alias_seq', 1, false); SELECT setval('node_alias_seq', 1, false);
`) `)
db.aliasCache = NewNodeAliasCache(db) db.aliasCache = NewNodeAliasCache(db)