order by downloaded time to improve ebs read performance

This commit is contained in:
Joe Lothan 2026-05-26 23:10:53 -04:00
parent df2eaa251c
commit a799c05f81
4 changed files with 28 additions and 19 deletions

View file

@ -21,7 +21,7 @@ SET work_mem = '2GB';
\timing on
CREATE TEMP TABLE best_icons AS
SELECT DISTINCT ON (host_id) host_id, icon_hash
SELECT DISTINCT ON (host_id) host_id, icon_hash, downloaded_at
FROM icons
WHERE scan_state = 'completed'
AND icon_hash IS NOT NULL
@ -50,7 +50,7 @@ ORDER BY host_id,
\echo 'Step 2: Updating hosts...'
UPDATE hosts h SET best_icon_hash = b.icon_hash
UPDATE hosts h SET best_icon_hash = b.icon_hash, icon_downloaded_at = b.downloaded_at
FROM best_icons b WHERE h.id = b.host_id;
\timing off