a better query to delete from hashtags
old query:
Delete on hashtags (cost=5089.81..5521.63 rows=6160 width=18)
-> Hash Semi Join (cost=5089.81..5521.63 rows=6160 width=18)
Hash Cond: (hashtags.id = ht.id)
-> Seq Scan on hashtags (cost=0.00..317.28 rows=17528 width=14)
-> Hash (cost=5012.81..5012.81 rows=6160 width=20)
-> Merge Anti Join (cost=0.70..5012.81 rows=6160 width=20)
Merge Cond: (ht.id = hto.hashtag_id)
-> Index Scan using hashtags_pkey on hashtags ht (cost=0.29..610.53 rows=17528 width=14)
-> Index Scan using hashtags_objects_pkey on hashtags_objects hto (cost=0.42..3506.48 rows=68158 width=14)
new query:
Delete on hashtags ht (cost=0.70..5012.81 rows=6160 width=12)
-> Merge Anti Join (cost=0.70..5012.81 rows=6160 width=12)
Merge Cond: (ht.id = hto.hashtag_id)
-> Index Scan using hashtags_pkey on hashtags ht (cost=0.29..610.53 rows=17528 width=14)
-> Index Scan using hashtags_objects_pkey on hashtags_objects hto (cost=0.42..3506.48 rows=68158 width=14)