Re: [GENERAL] How do you decide what aggregates to add?

2017-10-20 Thread Tom Lane
Seamus Abshere  writes:
> Who decides if a seemingly-useful aggregate is added to Postgres?

There's no particularly well-defined process for it, but as far as
these items ago:

> 1. I just discovered first()/last() as defined in the wiki [1], where
> it's noted that conversion from Access or Oracle is much easier with
> them.

Those are (a) undefined as to precise behavior, (b) redundant with
the first_value/last_value window functions, which *are* well defined
(not to mention SQL-standard), and (c) easy enough to make in SQL if
you want them despite (a) and (b).  So I don't really see them
getting over the hump.

> 2. We use our "homemade" jsonb_object_agg(jsonb) constantly, which is
> modeled off of (built-in) json_object_agg(name, value) and (built-in)
> jsonb_agg(expression). [2]

I dunno, the semantics of using jsonb_concat as an aggregate transfn
seem pretty squishy to me.  It's certainly much less well-defined
as to what you get than for either of the existing aggs you mention.

The short answer really is that we spend a lot of sweat on making Postgres
extensible so that we don't have to put in (and then maintain forever)
every little special-purpose function somebody might want.

regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[GENERAL] How do you decide what aggregates to add?

2017-10-20 Thread Seamus Abshere
hi,

Who decides if a seemingly-useful aggregate is added to Postgres? I
would like to advocate for a couple, but I worry that I'm
misunderstanding some community process that has decided _not_ to add
aggregates or something.

1. I just discovered first()/last() as defined in the wiki [1], where
it's noted that conversion from Access or Oracle is much easier with
them.
2. We use our "homemade" jsonb_object_agg(jsonb) constantly, which is
modeled off of (built-in) json_object_agg(name, value) and (built-in)
jsonb_agg(expression). [2]

Since building these into Postgres (though not fast C versions) is a
matter of a dozen lines of SQL, why haven't they been added already?
Seems like a great thing to brag about in release notes, etc.

Thanks for your thoughts,
Seamus

[1] https://wiki.postgresql.org/wiki/First/last_(aggregate)
[2] http://blog.faraday.io/how-to-aggregate-jsonb-in-postgres/

--
Seamus Abshere, SCEA
https://www.faraday.io
https://github.com/seamusabshere
https://linkedin.com/in/seamusabshere


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general