Add index to columns which are used regularly by worker and/or normal backend usage
Closed this issue · 1 comments
LordSimal commented
One of these queries is
SELECT QueuedJobs.id AS QueuedJobs__id, QueuedJobs.job_task AS QueuedJobs__job_task,
QueuedJobs.data AS QueuedJobs__data, QueuedJobs.job_group AS QueuedJobs__job_group,
QueuedJobs.reference AS QueuedJobs__reference, QueuedJobs.created AS QueuedJobs__created,
QueuedJobs.notbefore AS QueuedJobs__notbefore, QueuedJobs.fetched AS QueuedJobs__fetched,
QueuedJobs.completed AS QueuedJobs__completed, QueuedJobs.progress AS QueuedJobs__progress,
QueuedJobs.attempts AS QueuedJobs__attempts, QueuedJobs.failure_message AS QueuedJobs__failure_message,
QueuedJobs.workerkey AS QueuedJobs__workerkey, QueuedJobs.status AS QueuedJobs__status,
QueuedJobs.priority AS QueuedJobs__priority
FROM queued_jobs QueuedJobs
WHERE (completed) IS NULL
LIMIT 5
which is executed by doing
$this->QueuedJobs
->find('queued')
->limit(5)
and would go from 62ms to 0.1ms (on my local machine at least) if a index is added to queued_jobs.completed
(I have 11478 rows in that table right now)
Just wanted to ask if there is a specific reason why there is no index on this kind of column.
I just noticed it in my APM that this query was slower than I expected it to be.
dereuromark commented
Lets add it. No one checked before I assume