Files
tilbudgivern/backend/migrations/add_performance_indexes.sql

21 lines
1.0 KiB
SQL

-- Performance optimization: Add missing indexes to improve query performance
-- Created: 2025-12-27
-- Add indexes to bygma_products table if they don't exist
-- These columns are queried in packageService.findRealMaterial()
CREATE INDEX IF NOT EXISTS idx_bygma_tekst ON bygma_products(tekst);
CREATE INDEX IF NOT EXISTS idx_bygma_varenr ON bygma_products(vareNr);
CREATE INDEX IF NOT EXISTS idx_bygma_active_varegrp ON bygma_products(is_active, varegrp);
-- Add index to material_prices for name searches
CREATE INDEX IF NOT EXISTS idx_material_name ON material_prices(name);
-- Add composite index for OCR materials search queries
CREATE INDEX IF NOT EXISTS idx_ocr_materials_search ON ocr_materials(name, sku, material_category);
-- Add index for project_quotes queries by type
CREATE INDEX IF NOT EXISTS idx_project_quotes_type_rate ON project_quotes(project_type, labor_rate);
-- Add index for document date sorting in ocr_documents
CREATE INDEX IF NOT EXISTS idx_ocr_documents_date ON ocr_documents(document_date, document_type);