As a quick follow up I just did an explain on the query,
Aggregate (cost=258007258.87..258007258.88 rows=1 width=8)
-> Nested Loop (cost=0.00..184292254.83 rows=14743000807 width=16) -> Seq Scan on t1 (cost=0.00..3796.41 rows=263141 width=8) -> Materialize (cost=0.00..1088.40 rows=56027 width=8) -> Seq Scan on t2 (cost=0.00..808.27 rows=56027 width=8)
It seems it has to do a loop on 14 billion rows? Can someone explain why this would happen?
Thanks,
Teddy From: Teddy Schmitz
Sent: Thursday, February 16, 2017 12:32:41 PM To: pgsql-general@xxxxxxxxxxxxxx Subject: Problems with Greatest Hello,
I have a query using Greatest that hangs and never returns when called with two tables.
Postgres Version: 9.6
Tables t1{ id bigint }
t2 { id bigint }
they are sharing a sequence
the query select greatest(max(t1.id), max(t2.id)) from t1, t2; |