Re: Any thoughts on a better approach to this query? - Mailing list pgsql-general

From David G. Johnston
Subject Re: Any thoughts on a better approach to this query?
Date
Msg-id CAKFQuwadJNir8L6ft7Px65_BxqRxjE5=eaV5uAwP_Emq56hkYA@mail.gmail.com
Whole thread Raw
In response to Re: Any thoughts on a better approach to this query?  (Marc Mamin <M.Mamin@intershop.de>)
List pgsql-general
On Sat, Sep 5, 2015 at 8:36 AM, Marc Mamin <M.Mamin@intershop.de> wrote:

   array_not_nulls(array_agg(case when type='A' then link end ))as ar_a,
   array_not_nulls(array_agg(case when type='B' then link end ))as ar_b,
   array_not_nulls(array_agg(case when type NOT IN ('A', 'B') then link end)) as ar_others


​Yeah.  I'm not sure why I didn't tend toward the array_agg approach since I have made use of it previously.  It cleans up a bit but not as much as I was hoping - but also not seeing.  The preponderance of case statements​
 
​ and array slicing is still present.  I image trying to write some kind of "shift" function but that doesn't mesh well with set theory; it seems to be a procedural concept which I suspect would be considerably worse performing.

Thanks for the suggestion and once I get back on that project I'm intended to do a barebones performance comparison of the two which I'll follow up with.

David J.

pgsql-general by date:

Previous
From: Michael Paquier
Date:
Subject: Re: log_statement = 'mod' does not log all data modifying statements
Next
From: Melvin Davidson
Date:
Subject: Bugs with like_option in CREATE TABLE