I am trying to improve the performance of this query using joins instead of IN
s.
Also I am using the GUI tablePlus with Postgres. What are some good tools to assist with performance?
UPDATE app_public.challenge_progress
SET "current" = 0
WHERE status = 'IN_PROGRESS'
AND milestone_id IN
(SELECT cp.milestone_id
FROM app_public.challenge_milestones cm
JOIN app_public.challenge_progress cp ON cm.milestone_id = cp.milestone_id
WHERE cp.milestone_id IN
(SELECT milestone_id
FROM app_public.challenge_milestones
WHERE TYPE like '%_MONTHLY'))
I have tried this but I am not sure if it's better perf:
UPDATE app_public.challenge_progress
SET "current" = 0
FROM app_public.challenge_milestones cm
JOIN app_public.challenge_progress cp ON cm.milestone_id = cp.milestone_id
WHERE cp.status = 'IN_PROGRESS'
AND cm."type" like '%_MONTHLY'