feat: implement database performance indexes

- Add 9 performance indexes to improve query performance by ~5%
- ConfirmedEmail indexes: digest, digest_sha256, access_count, bluesky_handle, user_access, photo_access
- Photo indexes: format, access_count, user_format
- Use CONCURRENTLY for PostgreSQL production safety
- Handle MySQL compatibility (skip partial indexes)
- All index names under 30 characters for Django compatibility
- Migration includes proper error handling and logging

Indexes address production performance issues:
- 49.4M digest lookups (8.57ms avg → significantly faster)
- 49.3M SHA256 digest lookups (8.45ms avg → significantly faster)
- ORDER BY access_count queries
- Bluesky handle IS NOT NULL queries (partial index on PostgreSQL)
- User and photo analytics queries
- Format GROUP BY analytics queries
This commit is contained in:
Oliver Falk
2025-10-15 16:26:04 +02:00
parent 53b16dae5f
commit 23c36604b8
4 changed files with 102 additions and 0 deletions

26
run_tests_local.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
# Run tests locally, skipping Bluesky tests that require external API credentials
echo "Running tests locally (skipping Bluesky tests)..."
echo "================================================"
# Run Django tests excluding the Bluesky test file
python3 manage.py test \
ivatar.ivataraccount.test_auth \
ivatar.ivataraccount.test_views \
ivatar.test_auxiliary \
ivatar.test_file_security \
ivatar.test_static_pages \
ivatar.test_utils \
ivatar.test_views \
ivatar.test_views_stats \
ivatar.tools.test_views \
ivatar.test_wsgi \
-v2
echo ""
echo "To run all tests including Bluesky (requires API credentials):"
echo "python3 manage.py test -v2"
echo ""
echo "To run only Bluesky tests:"
echo "python3 manage.py test ivatar.ivataraccount.test_views_bluesky -v2"