Skip to content

GraphQL: Allow filtering runners by active status

What does this MR do and why?

Describe in detail what your merge request does and why.

This MR adds an active argument to the RunnersResolver, to make up for the deprecated ACTIVE/PAUSED values from CiRunnerStatus.

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

query getRunners {
  runners(active:false) {
    nodes {
      id
      description
      shortSha
      contactedAt
      active
    }
  }
}

Database query plan

Sorted on created_at

Before adding index

Execution plan
 Limit  (cost=0.43..1390.48 rows=100 width=232) (actual time=2.098..26.865 rows=100 loops=1)
   Buffers: shared hit=17522
   I/O Timings: read=0.000 write=0.000
   ->  Index Scan using index_ci_runners_on_created_at_desc_and_id_desc on public.ci_runners  (cost=0.43..501459.93 rows=36075 width=232) (actual time=2.095..26.833 rows=100 loops=1)
         Filter: (NOT ci_runners.active)
         Rows Removed by Filter: 16923
         Buffers: shared hit=17522
         I/O Timings: read=0.000 write=0.000

After adding index

Execution plan
 Limit  (cost=0.29..97.18 rows=100 width=232) (actual time=0.173..0.984 rows=100 loops=1)
   Buffers: shared hit=100 read=2
   I/O Timings: read=0.068 write=0.000
   ->  Index Scan using index_ci_runners_on_created_at_and_id_where_inactive on public.ci_runners  (cost=0.29..32971.58 rows=34030 width=232) (actual time=0.170..0.962 rows=100 loops=1)
         Buffers: shared hit=100 read=2
         I/O Timings: read=0.068 write=0.000

Sorted on contacted_at

Before adding index

Execution plan
 Limit  (cost=0.56..1782.29 rows=100 width=232) (actual time=0.967..2001.987 rows=100 loops=1)
   Buffers: shared hit=1316486 read=7156
   I/O Timings: read=246.872 write=0.000
   ->  Index Scan using index_ci_runners_on_contacted_at_desc_and_id_desc on public.ci_runners  (cost=0.56..606325.01 rows=34030 width=232) (actual time=0.964..2001.869 rows=100 loops=1)
         Filter: (NOT ci_runners.active)
         Rows Removed by Filter: 1323851
         Buffers: shared hit=1316486 read=7156
         I/O Timings: read=246.872 write=0.000

After adding index

Execution plan
 Limit  (cost=0.29..93.57 rows=100 width=232) (actual time=0.136..1.661 rows=100 loops=1)
   Buffers: shared hit=100 read=2
   I/O Timings: read=0.055 write=0.000
   ->  Index Scan using index_ci_runners_on_contacted_at_and_id_where_inactive on public.ci_runners  (cost=0.29..31743.07 rows=34030 width=232) (actual time=0.134..1.639 rows=100 loops=1)
         Buffers: shared hit=100 read=2
         I/O Timings: read=0.055 write=0.000

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Part of #347208 (closed)

Edited by Pedro Pombeiro

Merge request reports

Loading