From a65fa6896b3e6a6c8d6e055655fde78154ed6707 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 9 Aug 2026 15:55:37 +0300 Subject: [PATCH] skip sunqueries --- src/Appwrite/Platform/Tasks/ScheduleBase.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index efa9a0f8eb..78c120faf2 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -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);