From d1d4e124ff8ca86423a5fa71b90c0b9000b2faa2 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 27 Jan 2025 13:05:43 -0500 Subject: [PATCH] Avoiding inner joins for up.sql --- .../up.sql | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/migrations/2024-12-12-222846_add_search_combined_table/up.sql b/migrations/2024-12-12-222846_add_search_combined_table/up.sql index a434ed024..5b7ac75be 100644 --- a/migrations/2024-12-12-222846_add_search_combined_table/up.sql +++ b/migrations/2024-12-12-222846_add_search_combined_table/up.sql @@ -26,46 +26,42 @@ CREATE INDEX idx_search_combined_score ON search_combined (score DESC, id DESC); -- Updating the history INSERT INTO search_combined (published, score, post_id, comment_id, community_id, person_id) SELECT - p.published, + published, score, - id, + post_id, NULL::int, NULL::int, NULL::int FROM - post p - INNER JOIN post_aggregates pa ON p.id = pa.post_id + post_aggregates UNION ALL SELECT - c.published, + published, score, NULL::int, - id, + comment_id, NULL::int, NULL::int FROM - comment c - INNER JOIN comment_aggregates ca ON c.id = ca.comment_id + comment_aggregates UNION ALL SELECT - c.published, + published, users_active_month, NULL::int, NULL::int, - id, + community_id, NULL::int FROM - community c - INNER JOIN community_aggregates ca ON c.id = ca.community_id + community_aggregates UNION ALL SELECT - p.published, + published, post_score, NULL::int, NULL::int, NULL::int, - id + person_id FROM - person p - INNER JOIN person_aggregates pa ON p.id = pa.person_id; + person_aggregates;