Bug 1592976 Comment 1 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

I got quite a large subset of icons that very likely we can expire, they make up a 30% of my favicons database, so it sounds like a sensible expiration to do:

Favicons for redirecting pages:
```
SELECT page_url, icon_url FROM moz_icons i
JOIN moz_icons_to_pages ip ON icon_id = i.id
JOIN moz_pages_w_icons p ON page_id = p.id
JOIN moz_places h ON h.url_hash = page_url_hash
LEFT JOIN moz_bookmarks b ON b.fk = h.id
WHERE h.id IN(
  SELECT v.place_id
  FROM moz_historyvisits v
  JOIN moz_historyvisits v2 on v2.from_visit = v.id
  WHERE v2.visit_type IN(5,6)
)
AND b.id ISNULL
```

Favicons not updated in the last year for urls containing a ref:
```
SELECT page_url, icon_url, datetime(expire_ms / 1000, 'unixepoch') FROM moz_icons i
JOIN moz_icons_to_pages ip ON icon_id = i.id
JOIN moz_pages_w_icons p ON page_id = p.id
JOIN moz_places h ON h.url_hash = page_url_hash
LEFT JOIN moz_bookmarks b ON b.fk = h.id
WHERE expire_ms BETWEEN 1 AND strftime('%s','now','localtime','start of day','-365 days','utc') * 1000
AND b.id ISNULL AND page_url LIKE '%#%'
```

Overall, I think we should be safe removing icons that are expired more than 1 year ago and that fall into one of these categories (redirect source or url with ref) for urls that are not bookmarked.
This sounds like a sensible expiration to do:

Favicons for redirecting pages:
```
SELECT page_url, icon_url FROM moz_icons i
JOIN moz_icons_to_pages ip ON icon_id = i.id
JOIN moz_pages_w_icons p ON page_id = p.id
JOIN moz_places h ON h.url_hash = page_url_hash
LEFT JOIN moz_bookmarks b ON b.fk = h.id
WHERE h.id IN(
  SELECT v.place_id
  FROM moz_historyvisits v
  JOIN moz_historyvisits v2 on v2.from_visit = v.id
  WHERE v2.visit_type IN(5,6)
)
AND b.id ISNULL
```

Favicons not updated in the last year for urls containing a ref:
```
SELECT page_url, icon_url, datetime(expire_ms / 1000, 'unixepoch') FROM moz_icons i
JOIN moz_icons_to_pages ip ON icon_id = i.id
JOIN moz_pages_w_icons p ON page_id = p.id
JOIN moz_places h ON h.url_hash = page_url_hash
LEFT JOIN moz_bookmarks b ON b.fk = h.id
WHERE expire_ms BETWEEN 1 AND strftime('%s','now','localtime','start of day','-365 days','utc') * 1000
AND b.id ISNULL AND page_url LIKE '%#%'
```

Overall, I think we should be safe removing icons that are expired more than 1 year ago and that fall into one of these categories (redirect source or url with ref) for urls that are not bookmarked.

Back to Bug 1592976 Comment 1