skip sunqueries

This commit is contained in:
fogelito committed 2026-08-09 15:55:37 +03:00
1 parent ea174df83b
commit a65fa6896b
1 file changed
+13 -4
+13 -4
View File
@@ -237,10 +237,19 @@ abstract class ScheduleBase extends Action
foreach ($batches as $batch) {
$dbStart = microtime(true);
$documents = $dbForPlatform->find('projects', [
Query::equal('$id', $batch),
Query::limit(count($batch)),
]);
// The project's subquery attributes cost one query each, per project — five
// thousand extra queries for a batch of a thousand projects — and no
// schedule task reads them. The only attributes used here are accessedAt,
// teamId, database and the sequence, and the documents enqueued for the
// workers are reloaded there by id, so the stripped arrays never reach the
// code that needs them. Same group Action::$filters marks as Project.
$documents = $dbForPlatform->skipFilters(
fn () => $dbForPlatform->find('projects', [
Query::equal('$id', $batch),
Query::limit(count($batch)),
]),
['subQueryKeys', 'subQueryWebhooks', 'subQueryPlatforms', 'subQueryBlocks', 'subQueryDevKeys']
);
$dbQueryDuration += microtime(true) - $dbStart;
$transformStart = microtime(true);