diff --git a/docs/ConfigurationGuide.md b/docs/ConfigurationGuide.md index dba9c2ae..844bfc2e 100644 --- a/docs/ConfigurationGuide.md +++ b/docs/ConfigurationGuide.md @@ -798,6 +798,39 @@ Administrators can set the **site-wide default** colour scheme that is applied w UI_DEFAULT_COLOR_SCHEME=dark ``` +## Performance & Caching + +DocuElevate automatically optimises database access and uses Redis as a +caching layer for frequently accessed data. + +### Database Indexes + +On startup the application creates indexes on columns used for filtering, +sorting, and joining in the file listing and status computation queries: + +| Table | Column | Purpose | +|---|---|---| +| `files` | `created_at` | Default sort order | +| `files` | `mime_type` | MIME type filter & dropdown | +| `processing_logs` | `file_id` | Log retrieval by file | +| `processing_logs` | `timestamp` | Log ordering | +| `file_processing_steps` | `status` | Status filter sub-queries | + +These indexes are created idempotently on every startup so no manual +migration step is required. + +### Redis Query Cache + +When Redis is available (configured via `REDIS_URL`), DocuElevate caches +selected query results to avoid redundant database round-trips: + +| Cache Key | TTL | Description | +|---|---|---| +| `mime_types` | 120 s | Distinct MIME types shown in the file-list filter dropdown | + +The cache is **fail-open**: if Redis is unreachable the application falls +back to querying the database directly with no user-visible impact. + ## Configuration Examples ### Minimal Configuration diff --git a/tests/test_database_indexes.py b/tests/test_database_indexes.py index e5d34a55..52eb5aab 100644 --- a/tests/test_database_indexes.py +++ b/tests/test_database_indexes.py @@ -3,8 +3,7 @@ Tests for database performance indexes and schema migrations. """ import pytest -from sqlalchemy import create_engine, inspect, text -from sqlalchemy.orm import sessionmaker +from sqlalchemy import create_engine, inspect from sqlalchemy.pool import StaticPool from app.database import Base, _ensure_indexes