3 ms·
Well here's how I used it. My query was joining two tables with a left join and I was using the array_agg aggregate function (which aggregates a series of rows
by xtrumanx 12y ago
Well here's how I used it. My query was joining two tables with a left join and I was using the array_agg aggregate function (which aggregates a series of rows into a single array) on a record on the right table. Since the right table could be have rows that were all null I was getting aggregation of null values sometimes which I didn't want.
I didn't want to skips rows with null values (which is why I used a left join) since I needed the values of the left table always and thus had a conundrum.
With the filtered aggregation, I could tell PostgreSQL to not aggregate the null values. Here's the results of my query before and after using the filtered aggregate.
Before: {"name":"asd","id":2,"pages":[{"id":null,"data":null,"siteid":null}]}
After: {"name":"asd","id":2,"pages":null}