Pavel
-> Hash Join (cost=3827235.70..3874397.28 rows=2834 width=16) (actual time=115596.500..724273.041 rows=1892595 loops=1)
Hash Cond: (f_zendesktags_aaacrw6b1kat37e.ticket_id_id =
f_zendesktickets_aaarrsq5gxavz9o.id)
-> HashAggregate (cost=2950811.92..2967206.09 rows=1639417 width=4) (actual time=100035.413..114817.301 rows=12301177 loops=1)
-> Seq Scan on f_zendesktags_aaacrw6b1kat37e (cost=0.00..2319375.28 rows=126287328 width=4) (actual time=0.012..34951.543 rows=126287769 loops
same join with better estimation has about 20x faster
-> Hash Join (cost=3734043.50..3787700.73 rows=242545 width=12) (actual time=102901.756..137782.114 rows=1892595 loops=1)
Hash Cond: (f_zendesktags_aaacrw6b1kat37e.ticket_id_id =
f_zendesktickets_aaarrsq5gxavz9o.id)
-> HashAggregate (cost=2950811.92..2967206.09 rows=1639417 width=4) (actual time=99323.801..114452.277 rows=12301177 loops=1)
-> Seq Scan on f_zendesktags_aaacrw6b1kat37e (cost=0.00..2319375.28 rows=126287328 width=4) (actual time=0.033..34878.214 rows=126287769 loops=1)
-> Hash (cost=760482.69..760482.69 rows=1819911 width=12) (actual time=3576.360..3576.360 rows=1892595 loops=1)