Simplify selection of existing like objects in LikeRebuildDataWorker
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 4 Dec 2020 14:59:43 +0000 (15:59 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 4 Dec 2020 14:59:43 +0000 (15:59 +0100)
commit12eb5ace7a28ee55cd69dce0e7cff21ff2f954c0
tree04d7553e265f9a07bc94915e9d3b85491dce6779
parent76945dae32d57198dc75cb81625d09da70672e6d
Simplify selection of existing like objects in LikeRebuildDataWorker

Since the previous commit it is expected that only a single objectTypeID is hit
per worker execution in the usual case, because all objects for a single
objectTypeID are processed before proceeding to the next objectTypeID. This
patch optimizes this case by sending a separate query per objectTypeID to fetch
the existing like objects instead of combining all the objects in a single
query.

This should help MySQL in optimizing the query, because the objectTypeID (which
is the first column in the UNIQUE KEY on wcf1_like_object) is fixed for a
single query and this is immediately obvious without needing to scan all the
tuples passed to the IN(…) condition.

In the general case the number of queries does not change. In the iterations
where the last objectID for an objectTypeID is reached two queries will be sent
instead of a single one. Those two combined should be more efficient that the
single old query, though.
wcfsetup/install/files/lib/system/worker/LikeRebuildDataWorker.class.php