Skip to content
Snippets Groups Projects
Commit d9692197 authored by Krzysztof Leśniak's avatar Krzysztof Leśniak Committed by Dan Notestein
Browse files

Left joins on following columns

The issue was that resets were not effective and were not deleting rows.
This is because following is set to NULL in the incoming data.
So, when the query was joining against accounts table, the resets rows
were skipped, because there was no matching account.
To fix this the JOIN on the following column needs to be LEFT JOIN.
parent 146cb229
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !863. Comments created here will be created in the context of that merge request.
......@@ -278,7 +278,7 @@ AS $BODY$
FROM UNNEST(_follow_updates) AS upd
CROSS JOIN LATERAL UNNEST(upd.changes) AS ch(follower, following, block_num)
JOIN accounts_id AS r ON ch.follower = r.name
JOIN accounts_id AS g ON ch.following = g.name
LEFT JOIN accounts_id AS g ON ch.following = g.name
GROUP BY upd.id, upd.mode
ORDER BY upd.id
) AS upd_with_ids
......@@ -305,7 +305,7 @@ AS $BODY$
FROM UNNEST(_muted_updates) AS upd
CROSS JOIN LATERAL UNNEST(upd.changes) AS ch(follower, following, block_num)
JOIN accounts_id AS r ON ch.follower = r.name
JOIN accounts_id AS g ON ch.following = g.name
LEFT JOIN accounts_id AS g ON ch.following = g.name
GROUP BY upd.id, upd.mode
ORDER BY upd.id
) AS upd_with_ids
......@@ -332,7 +332,7 @@ AS $BODY$
FROM UNNEST(_blacklisted_updates) AS upd
CROSS JOIN LATERAL UNNEST(upd.changes) AS ch(follower, following, block_num)
JOIN accounts_id AS r ON ch.follower = r.name
JOIN accounts_id AS g ON ch.following = g.name
LEFT JOIN accounts_id AS g ON ch.following = g.name
GROUP BY upd.id, upd.mode
ORDER BY upd.id
) AS upd_with_ids
......@@ -359,7 +359,7 @@ AS $BODY$
FROM UNNEST(_follow_muted_updates) AS upd
CROSS JOIN LATERAL UNNEST(upd.changes) AS ch(follower, following, block_num)
JOIN accounts_id AS r ON ch.follower = r.name
JOIN accounts_id AS g ON ch.following = g.name
LEFT JOIN accounts_id AS g ON ch.following = g.name
GROUP BY upd.id, upd.mode
ORDER BY upd.id
) AS upd_with_ids
......@@ -386,7 +386,7 @@ AS $BODY$
FROM UNNEST(_follow_blacklisted_updates) AS upd
CROSS JOIN LATERAL UNNEST(upd.changes) AS ch(follower, following, block_num)
JOIN accounts_id AS r ON ch.follower = r.name
JOIN accounts_id AS g ON ch.following = g.name
LEFT JOIN accounts_id AS g ON ch.following = g.name
GROUP BY upd.id, upd.mode
ORDER BY upd.id
) AS upd_with_ids
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment