From 93de25e5b61972844f5f958ee0353c62e0d2d068 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 19 Feb 2024 19:45:52 +0100 Subject: [PATCH] Feature/add missing database indexes (#3026) * Add missing database indexes * Update changelog --- CHANGELOG.md | 8 ++++++++ .../migration.sql | 11 +++++++++++ prisma/schema.prisma | 5 +++++ 3 files changed, 24 insertions(+) create mode 100644 prisma/migrations/20240219182116_added_missing_indexes/migration.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index fae4b3527..a52b07c44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Added + +- Added an index for `id` to the account database table +- Added indexes for `dataSource` and `date` to the market data database table +- Added an index for `accountId` to the order database table + ## 2.53.1 - 2024-02-18 ### Added diff --git a/prisma/migrations/20240219182116_added_missing_indexes/migration.sql b/prisma/migrations/20240219182116_added_missing_indexes/migration.sql new file mode 100644 index 000000000..a18639489 --- /dev/null +++ b/prisma/migrations/20240219182116_added_missing_indexes/migration.sql @@ -0,0 +1,11 @@ +-- CreateIndex +CREATE INDEX "Account_id_idx" ON "Account"("id"); + +-- CreateIndex +CREATE INDEX "MarketData_dataSource_idx" ON "MarketData"("dataSource"); + +-- CreateIndex +CREATE INDEX "MarketData_date_idx" ON "MarketData"("date"); + +-- CreateIndex +CREATE INDEX "Order_accountId_idx" ON "Order"("accountId"); diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 615610fa3..ae36b00bf 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -39,6 +39,7 @@ model Account { Order Order[] @@id([id, userId]) + @@index([id]) } model AccountBalance { @@ -81,6 +82,8 @@ model MarketData { symbol String @@unique([dataSource, date, symbol]) + @@index([dataSource]) + @@index([date]) @@index([symbol]) } @@ -103,6 +106,8 @@ model Order { SymbolProfile SymbolProfile @relation(fields: [symbolProfileId], references: [id]) User User @relation(fields: [userId], references: [id]) tags Tag[] + + @@index([accountId]) } model Platform {