Re: [HACKERS] Faster array_length()

2014-05-02 Thread Hadi Moshayedi
Thanks for looking into this. > With that in mind, I was surprised that your test case showed any > improvement at all --- it looks like the arrays aren't getting compressed > for some reason. > > You are right, it seems that they were not getting compressed, probably because the arrays were "seq

Re: [HACKERS] Faster array_length()

2014-05-02 Thread Tom Lane
Hadi Moshayedi writes: > The attached patch improves the performance of array_length() by detoasting > only the overhead part of the datum. It looks to me like this would actually make things worse for cases where the input array wasn't toasted-out-of-line (because it would uselessly make a copy

[HACKERS] Faster array_length()

2014-05-02 Thread Hadi Moshayedi
Hello, The attached patch improves the performance of array_length() by detoasting only the overhead part of the datum. Here is a test case: postgres=# create table array_length_test as select array_agg(a) a from generate_series(1, 1) a, generate_series(1, 1) b group by b; Without the p