Hi My idea is using new ArrayBuilder optimized for building multidimensional arrays with own State type. I think so casting to ArrayBuildState is base of our problems, so I don't would to do. Code in array_agg_* is simple, little bit more complex code is in nodeSubplan.c. Some schematic changes are in attachments.
Regards Pavel 2014-10-25 15:58 GMT+02:00 Ali Akbar <the.ap...@gmail.com>: > you can check it? We can test, how performance lost we get. As second >> benefit we can get numbers for introduction new optimized array builder >> > > array_agg(anyarray) with deconstruct_array, unchanged accumArrayResult and > makeMdArrayResult: > >> INSERT 0 1 >> Time: 852,527 ms >> INSERT 0 1 >> Time: 844,275 ms >> INSERT 0 1 >> Time: 858,855 ms >> INSERT 0 1 >> Time: 861,072 ms >> INSERT 0 1 >> Time: 952,006 ms >> INSERT 0 1 >> Time: 953,918 ms >> INSERT 0 1 >> Time: 926,945 ms >> INSERT 0 1 >> Time: 923,692 ms >> INSERT 0 1 >> Time: 940,916 ms >> INSERT 0 1 >> Time: 948,700 ms >> INSERT 0 1 >> Time: 933,333 ms >> INSERT 0 1 >> Time: 948,869 ms >> INSERT 0 1 >> Time: 847,113 ms >> INSERT 0 1 >> Time: 908,572 ms > > > > Total: 12776.83 > > Avg: 912,63 > > > with last patch (v10): > >> INSERT 0 1 >> Time: 643,339 ms >> INSERT 0 1 >> Time: 608,010 ms >> INSERT 0 1 >> Time: 610,465 ms >> INSERT 0 1 >> Time: 613,931 ms >> INSERT 0 1 >> Time: 616,466 ms >> INSERT 0 1 >> Time: 634,754 ms >> INSERT 0 1 >> Time: 683,566 ms >> INSERT 0 1 >> Time: 656,665 ms >> INSERT 0 1 >> Time: 630,096 ms >> INSERT 0 1 >> Time: 607,564 ms >> INSERT 0 1 >> Time: 610,353 ms >> INSERT 0 1 >> Time: 626,816 ms >> INSERT 0 1 >> Time: 610,450 ms >> INSERT 0 1 >> Time: 614,342 ms >> > > > Total: 8842,7 >> Avg: 631,6 > > > It's 30% faster (i tried varlena element - text). I tried several times > and it's consistent in +/- 30%. > > > quick & dirty non-optimized patch and the test script attached. > > Regards, > -- > Ali Akbar >
ExecScanSubPlan(...) ArrayBuildState *astate = NULL; MdArrayBuildState *mdastate = NULL; bool use_md_array_builder; if (subLinkType == MULTIEXPR_SUBLINK) { } if (subLinkType == ARRAY_SUBLINK) { Assert(subplan->firstColType == tdesc->attrs[0]->attypid); /* use a fast array multidimensional builder when input is a array */ use_md_array_builder = OidIsValid(get_element_type(subplan->firstColType); } ... for (slot = ExecProcNode() ...) { if (subLinkType == ARRAY_SUBLINK) { Datum dvalue; bool disnull; found = true; dvalue = slot_getattr(slot, 1, &disnull); if (use_md_array_builder) mdastate = accumMdArray(...); else astate = accumArrayResult(...); } } /* endfor */ if (subLinkType == ARRAY_SUBLINK) { .. if (astate != NULL) node->curArray = makeArrayResult(astate, ...); else if (mdastate != NULL) node->curArray = makeMdArray(mdastate, ...); else { } }
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers