Steve Rowe wrote:
Alan Kirk wrote:
Steve Rowe wrote:
Yes I do a Dimix before I do an element insert but.
I wouldn't bother with that unless your objective is to flag duplicates; otherwise it's a waste of processor cycles. If the element exists then DimensionElementInsert just ignores it.
I've done some testing on this and doing a Dimix is faster than doing DimensionElementInsert, even if the element already exists. At a guess I would say that a DimensionElementInsert is not ignored for elements that already exist its just that as a user you can't tell the difference between re-insertion and ignore for an element that exists. Looking at a dimension via Dimix vs updating a dimension has a significant time difference.
In the special case where you build a dimension from scratch then the Dimix is wasted I agree, in the more general case where you are applying small incremental updates there is a performance benefit from doing a Dimix before your insert.
I'm not sure that I'd say significant but yes, I agree that my tests (under 10.1) confirm yours. I'm surprised as it's not just a DimIx but an If() as well which I would have expected to slow things down a bit. That's why I prefer to avoid them if not absolutely necessary. (That may just be my VBA background kicking in, though.)
I created a chore which:
- Process 0: Deleted and recreated a dimension with only a single element;
- Process 1: Inserted elements (1 million elements in the first test, 2 million in the second; the numbers being chosen mainly to slow it down enough to time it);
- Process 2: Inserted the same elements;
- Process 3: Wrapped the insert command inside an If DimIx = 0 block.
In all cases these were done in the Prolog to take any data source speed issues out of the equation. Aside from the If block in process 3 the code in all 3 processes was identical.
Test 1 was 11 seconds, 11 seconds, 9 seconds for processes 1, 2 and 3 respectively.
Test 2 was 22 seconds, 22 seconds, 19 seconds.
So the difference isn't
huge, and if you're expecting that the majority of the elements
won't be there already (a variation on the special case that you mention) you'd probably save a few cycles and code lines by not checking... but for the far more common case of refreshing an existing dimension it may be worth it just to squeeze that little bit of extra speed out of it.