Speedup document database storage
Description
Optimize the actual storage
The main problem is that every single xobject property is handled separately, which produce a lot of requests, making the whole process very slow.
We need to optimize how we use Hibernate for it to do much more in bulk.
Only store what changed
Compare with the original document
While this should work well, it means putting a lot of trust in the original document. On the other hand, having a bad original document can cause quite some problems already (especially with listeners).
Rely on the dirty flag
Each object property has a "isValueDirty" flag, which is supposed to indicate if it's been modified. We could decide to skip the property if "isValueDirty" is false. This information is currently not used at all it seems (so we would need to make sure it's always accurate since it's rarely the case when something is not used…).
Only load (and so store) what is needed
The idea would be to reduce the whole read/write communication with the database by loading and storing only what's manipulated.
This has a big potential, but it's also a huge change in terms of logic, and is quite a retro compatibility challenge: many things currently navigate the whole document (to clone it, to find what changed, etc.) and just implementing lazy loading in XWikiDocument would actually make things much slower if we don't make sure that all access of the document don't end up loading it entirely every time if not needed.
Thomas Mortagne