Em 13/11/2019 17:40, Jeff Janes
escreveu:
Hi Jeff, I don't think the "HAVING" clause is havin any effect on the estimates: WITHOUT "HAVING": Group (cost=1245134.08..1279680.28 rows=3454620 width=14) Group Key: c.concod, cp.conparnum, cp.conpardatven -> Sort (cost=1245134.08..1253770.63 rows=3454620 width=14) Sort Key: c.concod, cp.conparnum, cp.conpardatven -> Hash Join (cost=34366.64..869960.70 rows=3454620 width=14) Hash Cond: (cp.concod = c.concod) -> Seq Scan on contrato_parcela cp (cost=0.00..804248.08 rows=11941308 width=14) -> Hash (cost=23436.55..23436.55 rows=874407 width=8) -> Index Only Scan using contrato_iu0004 on contrato c (cost=0.43..23436.55 rows=874407 width=8) Index Cond: (carcod = 100) WITH "HAVING": GroupAggregate (cost=1245144.88..1322874.51 rows=3454650 width=14) Group Key: c.concod, cp.conparnum, cp.conpardatven Filter: (count(*) > 1) -> Sort (cost=1245144.88..1253781.51 rows=3454650 width=14) Sort Key: c.concod, cp.conparnum, cp.conpardatven -> Hash Join (cost=34366.64..869968.02 rows=3454650 width=14) Hash Cond: (cp.concod = c.concod) -> Seq Scan on contrato_parcela cp (cost=0.00..804255.13 rows=11941413 width=14) -> Hash (cost=23436.55..23436.55 rows=874407 width=8) -> Index Only Scan using contrato_iu0004 on contrato c (cost=0.43..23436.55 rows=874407 width=8) Index Cond: (carcod = 100) Maybe PostgreSQL can't find a way to calculate having estimates? |