mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-23 03:31:09 -05:00
Improve park listing performance with optimized queries and caching
Implement performance enhancements for park listing by optimizing database queries, introducing efficient caching mechanisms, and refining pagination for a significantly faster and smoother user experience. Replit-Commit-Author: Agent Replit-Commit-Session-Id: c446bc9e-66df-438c-a86c-f53e6da13649 Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
54
apps/parks/migrations/0002_add_performance_indexes.py
Normal file
54
apps/parks/migrations/0002_add_performance_indexes.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# Generated by Django 5.2.6 on 2025-09-23 22:29
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('parks', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
# Performance indexes for frequently filtered fields
|
||||
migrations.RunSQL(
|
||||
"CREATE INDEX IF NOT EXISTS idx_parks_status_operator ON parks_park(status, operator_id);",
|
||||
reverse_sql="DROP INDEX IF EXISTS idx_parks_status_operator;"
|
||||
),
|
||||
migrations.RunSQL(
|
||||
"CREATE INDEX IF NOT EXISTS idx_parks_park_type_status ON parks_park(park_type, status);",
|
||||
reverse_sql="DROP INDEX IF EXISTS idx_parks_park_type_status;"
|
||||
),
|
||||
migrations.RunSQL(
|
||||
"CREATE INDEX IF NOT EXISTS idx_parks_opening_year_status ON parks_park(opening_year, status) WHERE opening_year IS NOT NULL;",
|
||||
reverse_sql="DROP INDEX IF EXISTS idx_parks_opening_year_status;"
|
||||
),
|
||||
migrations.RunSQL(
|
||||
"CREATE INDEX IF NOT EXISTS idx_parks_ride_count_coaster_count ON parks_park(ride_count, coaster_count) WHERE ride_count IS NOT NULL;",
|
||||
reverse_sql="DROP INDEX IF EXISTS idx_parks_ride_count_coaster_count;"
|
||||
),
|
||||
migrations.RunSQL(
|
||||
"CREATE INDEX IF NOT EXISTS idx_parks_average_rating_status ON parks_park(average_rating, status) WHERE average_rating IS NOT NULL;",
|
||||
reverse_sql="DROP INDEX IF EXISTS idx_parks_average_rating_status;"
|
||||
),
|
||||
# Search optimization index
|
||||
migrations.RunSQL(
|
||||
"CREATE INDEX IF NOT EXISTS idx_parks_search_text_gin ON parks_park USING gin(search_text gin_trgm_ops);",
|
||||
reverse_sql="DROP INDEX IF EXISTS idx_parks_search_text_gin;"
|
||||
),
|
||||
# Location-based indexes for ParkLocation
|
||||
migrations.RunSQL(
|
||||
"CREATE INDEX IF NOT EXISTS idx_parklocation_country_city ON parks_parklocation(country, city);",
|
||||
reverse_sql="DROP INDEX IF EXISTS idx_parklocation_country_city;"
|
||||
),
|
||||
# Company name index for operator filtering
|
||||
migrations.RunSQL(
|
||||
"CREATE INDEX IF NOT EXISTS idx_company_name_roles ON parks_company USING gin(name gin_trgm_ops, roles);",
|
||||
reverse_sql="DROP INDEX IF EXISTS idx_company_name_roles;"
|
||||
),
|
||||
# Timestamps for ordering and filtering
|
||||
migrations.RunSQL(
|
||||
"CREATE INDEX IF NOT EXISTS idx_parks_created_at_status ON parks_park(created_at, status);",
|
||||
reverse_sql="DROP INDEX IF EXISTS idx_parks_created_at_status;"
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user