ci_runners.contacted_at is not indexed and used for checking runner activity
For example, we run queries such as:
SELECT COUNT(*) FROM ci_runners WHERE active=true AND contacted_at >= NOW() - '60 minutes'::INTERVAL;
The table ci_runners.contacted_at
is not indexed, resulting in the following query plan:
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------
Aggregate (cost=15131.14..15131.15 rows=1 width=8) (actual time=24.513..24.514 rows=1 loops=1)
-> Seq Scan on ci_runners (cost=0.00..15118.05 rows=5237 width=0) (actual time=0.093..23.155 rows=5501 loops=1)
Filter: (active AND (contacted_at >= (now() - '01:00:00'::interval)))
Rows Removed by Filter: 12959
Planning time: 0.122 ms
Execution time: 24.540 ms