StaticEntity Get action in loop performance

Hi, we have a list with an attribute that is populated from StaticEntity using GetAction (GetStaticEntityName(Id:XXX).StaticEntityName.Label). Is it a bad practice and degrade performance as when static entities are used in loops/lists same as normal entities? 

Hi Mykola,

I'd say you should cache this in a function GetLabelById or something like that.

In a previous project in P10, there was a big import process which was taking a long time and was using mechanisms like what you meant to translate labels to ids and vice-versa.

After changing it to cached actions such as the one I mentioned, the import became much faster (like 50%).

So yes, I'd say it's better to cache this kind of things since the result does not change on runtime and when you change it and publish it, the cache will be invalidated.


Hi Mykola,

As far as I know, they are handled like normal entities in that case. Of course a loop always takes time, especially if it includes a lot of database access. Also, as I remember correctly, the Get<Entity>Action always returns the full record, not only the field that you need. As an optimization I would think of the following:

- Can't you join the static entity in a query directly, so you already have the label value?

- Or you can create an action (with an aggregate in it) that returns *only* the label based on the Id, and cache that action. Instead of an action you could also just use an aggregate and cache that one.

Maybe somebody can say something about the fact that a Get<Entity>() action always returns the full record and if these system actions are being cached.

Good luck!