Skip to content

Commit 56c163b

Browse files
committed
refactor: optimize database performance with new indexes
This commit introduces new SQL migration files to create indexes that enhance query performance for protocol components.
1 parent d11badd commit 56c163b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DROP INDEX IF EXISTS idx_protocol_system_id_external_id;
2+
DROP INDEX IF EXISTS idx_protocol_component_system_id;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Database Query Optimizations
2+
3+
## 1. EntryPoint Query Optimization
4+
5+
- **Purpose**: Speed up lookup queries on `(protocol_system_id, external_id)` for EntryPoint resolution.
6+
- **Initial Execution Time**: 130ms
7+
- **Optimized Execution Time**: 0.1ms
8+
9+
**Index Added:**
10+
11+
```sql
12+
CREATE INDEX IF NOT EXISTS idx_protocol_system_id_external_id ON protocol_component (protocol_system_id, external_id);
13+
```
14+
15+
## 1. ProtocolComponent count Query Optimization
16+
17+
- **Purpose**: Improve efficiency of count queries (e.g., for pagination) by filtering on protocol_system_id.
18+
- **Initial Execution Time**: 100ms
19+
- **Optimized Execution Time**: 50ms
20+
21+
**Index Added:**
22+
23+
```sql
24+
CREATE INDEX idx_protocol_component_system_id ON protocol_component (protocol_system_id);
25+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CREATE INDEX IF NOT EXISTS idx_protocol_system_id_external_id ON protocol_component (protocol_system_id, external_id);
2+
CREATE INDEX idx_protocol_component_system_id ON protocol_component (protocol_system_id);

0 commit comments

Comments
 (0)