From e2bd5668ba9aed9f35085d22ebc1bf4e2179463f Mon Sep 17 00:00:00 2001 From: Dan LaManna Date: Mon, 5 Jun 2023 09:48:33 -0400 Subject: [PATCH] Refresh search view concurrently --- dandiapi/api/tasks/scheduled.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dandiapi/api/tasks/scheduled.py b/dandiapi/api/tasks/scheduled.py index e75b8e123..7b99b4588 100644 --- a/dandiapi/api/tasks/scheduled.py +++ b/dandiapi/api/tasks/scheduled.py @@ -57,9 +57,14 @@ def send_pending_users_email() -> None: @shared_task(soft_time_limit=60) def refresh_materialized_view_search() -> None: - """Execute a REFRESH MATERIALIZED VIEW query to update the view used by asset search.""" + """ + Execute a REFRESH MATERIALIZED VIEW query to update the view used by asset search. + + Note that this is a "concurrent" refresh, which means that the view will be + updated without locking the table. + """ with connection.cursor() as cursor: - cursor.execute('REFRESH MATERIALIZED VIEW asset_search;') + cursor.execute('REFRESH MATERIALIZED VIEW CONCURRENTLY asset_search;') def register_scheduled_tasks(sender: Celery, **kwargs):