I've noticed that while starting Elgg 1.8 core, there are around 2*#plugins calls to DB being made. The calls are made while instantiating data rows to ElggPlugin objects.
I understand why the mechanism works like that, but it obviously seems like a thing that should be optimized. Why not to reuse data already downloaded in elgg_get_entities instead of calling
SELECT * from elgg_entities where guid=PLUGIN_GUID and ( (1 = 1) and enabled='yes')
for every plugin.
Than for every plugin we download ELggObject fields:
SELECT * from elgg_objects_entity where guid=2
Question is, why don't we reuse already downloaded data from first call, and why don't we rebuild instantiating process (entity_row_to_elggstar and constructing ElggObject) to support downloading additional data in single query.
To sum up, we could be making two DB calls to get all of the data much more efficient instead of making over 100 queries (I don't think it's likely to have non-trivial elgg service with less than 50 plugins in practice). It's especially important for ElggPlugin, but could be extended to more general mechanism.
The text was updated successfully, but these errors were encountered:
Just a thought, I've removed first king of calls by allowing ElggEntity->load function to process db row optionally to guid as parameter, and changing ElggObject constructor call. I also thought of something like passing second argument to get_data callback, to pass there some additional row info that could be used by the callback, and passed somehow to the constructor maybe? I'm not sure if it would be helpful if some more sophisticated mechanism is under development.
Are there some particular ticket's You're referring to?