Re: [GENERAL] Problems with Greatest

2017-02-15 Thread Thomas Kellerer
Teddy Schmitz schrieb am 16.02.2017 um 05:38: > 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 w

Re: [GENERAL] Problems with Greatest

2017-02-15 Thread Teddy Schmitz
Thanks for the link Pavel, that makes perfect sense now. Teddy From: David G. Johnston Sent: Thursday, February 16, 2017 12:42:36 PM To: Teddy Schmitz Cc: pgsql-general@postgresql.org Subject: [GENERAL] Problems with Greatest On Wednesday, February 15, 2017

[GENERAL] Problems with Greatest

2017-02-15 Thread David G. Johnston
On Wednesday, February 15, 2017, Teddy Schmitz > wrote: > > select greatest(max(t1.id), max(t2.id)) from t1, t2; > > I seriously doubt that the greatest function is a larger contributor to run time than the cross join between t1 and t2. David J.

Re: [GENERAL] Problems with Greatest

2017-02-15 Thread Pavel Stehule
2017-02-16 5:38 GMT+01:00 Teddy Schmitz : > 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=

Re: [GENERAL] Problems with Greatest

2017-02-15 Thread Teddy Schmitz
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 wi

[GENERAL] Problems with Greatest

2017-02-15 Thread Teddy Schmitz
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; The purpose was to call setval on t