Skip to content

Commit e937e8b

Browse files
committed
improve performance of find_chunks_by_dedup_key by introducing composite index
Signed-off-by: Karthik P S <[email protected]>
1 parent 0d80b71 commit e937e8b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/server/object_services/schemas/data_chunk_indexes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module.exports = [{
1717
{
1818
fields: {
1919
dedup_key: 1,
20+
system: 1,
21+
bucket: 1
2022
},
2123
options: {
2224
unique: false,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* Copyright (C) 2025 NooBaa */
2+
"use strict";
3+
4+
async function run({ dbg, db_client }) {
5+
/* After the index is dropped, a new composite index (system, bucket, dedup_key)
6+
will be created during bootstrap */
7+
const indexName = 'idx_btree_datachunks_dedup_key';
8+
9+
try {
10+
const pool = db_client.instance().get_pool();
11+
await pool.query(`DROP INDEX IF EXISTS ${indexName};`);
12+
13+
dbg.log0("Executed upgrade script for dropping index ", indexName);
14+
} catch (err) {
15+
dbg.error('An error ocurred in the upgrade process:', err);
16+
throw err;
17+
}
18+
}
19+
20+
module.exports = {
21+
run,
22+
description: 'Delete the "idx_btree_datachunks_dedup_key" index'
23+
};

0 commit comments

Comments
 (0)