Logic Machine Forum
Which is the faster: objects.tagcache or objecttags? - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Which is the faster: objects.tagcache or objecttags? (/showthread.php?tid=5315)



Which is the faster: objects.tagcache or objecttags? - rbourgeon - 21.03.2024

When the tags on an object are changed, which is updated faster? For instance, when adding a tag on an object, which will happen first between these two options?
  • Append the tag in the "tagcache" column of the corresponding row of the table "objects"
  • Add a new row in the "objecttags" table, containing the ID of the object + the tag just added

I'm asking the question because I'm conceiving a web app that might sometimes add/remove a lot of tags from a lot of objects. So, I want the JavaScript code to send an HTTP request to a .Lp endpoint that will fetch what are the current tags of the modified objects. In that context, I was wondering what would be the best practice in that .lp file

SELECT tagcache FROM objects WHERE id in (...)

orĀ 

SELECT object, tag FROM object in (...)


RE: Which is the faster: objects.tagcache or objecttags? - admin - 21.03.2024

You should use grp.gettags instead of doing direct db queries. Performance difference is minimal.


RE: Which is the faster: objects.tagcache or objecttags? - rbourgeon - 21.03.2024

And what if we want to update the tags of ALL objects because the tags of other objects might also have changed (because of external scripts)? To get the list of all objects, we would have to execute grp.all(), but since every item in this list already has a tagcache, would that be sufficient?

or would we have to loop over all the results of grp.all() and apply the function grp.gettags to each of the results? This seems a bit heavy


RE: Which is the faster: objects.tagcache or objecttags? - admin - 21.03.2024

Calling grp.gettags in a loop will be slower than using tagcache. For a large object list you can use tagcache directly.