|> Repo.delete_all(timeout: :infinity)
prune_hashtags_query = """
- delete from hashtags
- where id in (
- select id from hashtags as ht
- left join hashtags_objects as hto
- on hto.hashtag_id = ht.id
- where hto.hashtag_id is null)
+ DELETE FROM hashtags AS ht
+ WHERE NOT EXISTS (
+ SELECT 1 FROM hashtags_objects hto
+ WHERE ht.id = hto.hashtag_id)
"""
Repo.query(prune_hashtags_query)