Skip to content

Commit b800a43

Browse files
Pothulapatiroboquat
authored andcommitted
[gitpod-db] add index on workspaceDB.Type Column
For Telemetry queries to be less intensive on the CPU, We need to build Indexes to make the querying faster Signed-off-by: Tarun Pothulapati <[email protected]>
1 parent c0cbe79 commit b800a43

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

components/gitpod-db/src/typeorm/entity/db-workspace.ts

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class DBWorkspace implements Workspace {
7070
})
7171
shareable?: boolean;
7272

73+
@Index("ind_type")
7374
@Column({
7475
default: "regular",
7576
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3+
* Licensed under the GNU Affero General Public License (AGPL).
4+
* See License-AGPL.txt in the project root for license information.
5+
*/
6+
7+
import {MigrationInterface, QueryRunner} from "typeorm";
8+
import { indexExists } from "./helper/helper";
9+
10+
export class IndexWorkspaceType1647290507971 implements MigrationInterface {
11+
12+
public async up(queryRunner: QueryRunner): Promise<void> {
13+
const TABLE_NAME = "d_b_workspace";
14+
const TYPE_INDEX_NAME = "ind_type";
15+
if (!(await indexExists(queryRunner, TABLE_NAME, TYPE_INDEX_NAME))) {
16+
await queryRunner.query(`CREATE INDEX ${TYPE_INDEX_NAME} ON ${TABLE_NAME} (type)`);
17+
}
18+
}
19+
20+
public async down(queryRunner: QueryRunner): Promise<void> {
21+
}
22+
23+
}

0 commit comments

Comments
 (0)