Avoiding inner joins for up.sql

This commit is contained in:
Dessalines 2025-01-27 13:05:43 -05:00
parent 9db5355c05
commit d1d4e124ff

View file

@ -26,46 +26,42 @@ CREATE INDEX idx_search_combined_score ON search_combined (score DESC, id DESC);
-- Updating the history -- Updating the history
INSERT INTO search_combined (published, score, post_id, comment_id, community_id, person_id) INSERT INTO search_combined (published, score, post_id, comment_id, community_id, person_id)
SELECT SELECT
p.published, published,
score, score,
id, post_id,
NULL::int, NULL::int,
NULL::int, NULL::int,
NULL::int NULL::int
FROM FROM
post p post_aggregates
INNER JOIN post_aggregates pa ON p.id = pa.post_id
UNION ALL UNION ALL
SELECT SELECT
c.published, published,
score, score,
NULL::int, NULL::int,
id, comment_id,
NULL::int, NULL::int,
NULL::int NULL::int
FROM FROM
comment c comment_aggregates
INNER JOIN comment_aggregates ca ON c.id = ca.comment_id
UNION ALL UNION ALL
SELECT SELECT
c.published, published,
users_active_month, users_active_month,
NULL::int, NULL::int,
NULL::int, NULL::int,
id, community_id,
NULL::int NULL::int
FROM FROM
community c community_aggregates
INNER JOIN community_aggregates ca ON c.id = ca.community_id
UNION ALL UNION ALL
SELECT SELECT
p.published, published,
post_score, post_score,
NULL::int, NULL::int,
NULL::int, NULL::int,
NULL::int, NULL::int,
id person_id
FROM FROM
person p person_aggregates;
INNER JOIN person_aggregates pa ON p.id = pa.person_id;