IRSS: Add micro optimizations for revision database repository
If approved, this should (at least) be picked to all "upper" ILIAS versions/branches.
This PR suggests changing the approach used to persist resource information in \ILIAS\ResourceStorage\Revision\Repository\RevisionDBRepository::store.
Issues:
- Round-trips: 1 ×
SELECT+ (1 ×UPDATEor 1 ×INSERT) - Potential race condition (unlikely in the IRSS context): Time goes by between the
SELECTand (UPDATEorINSERT)- And specifically: Handling this in the application would have a lot of drawbacks (restriction of concurrency, slow, complexity depending on the approach) / Update: It seems to be already handled by the table names provided via
\ILIAS\ResourceStorage\Lock\LockingRepository::getNamesForLocking
- And specifically: Handling this in the application would have a lot of drawbacks (restriction of concurrency, slow, complexity depending on the approach) / Update: It seems to be already handled by the table names provided via
In both cases, for INSERT and UPDATE, we currently persist values for all database fields in il_resource_revision.
Furthermore, the primary of table il_resource_revision is a combined key: rid and version_number.
So to address the problems I mentioned above, I hereby suggest using \ilDBInterface::replace (I know, if a row does exist, REPLACE deletes it and inserts the new data, in one atomic step, which should not be a problem IMO) instead, which is (IMO) also more readable.
To debate on: Alternatively, we could use an INSERT INTO ... ON DUPLICATE KEY UPDATE ....