Skip to content

WIP: Add created_at index to audit_events table

What does this MR do?

This MR adds an index for audit_events on created_at and id.

Before:

gitlabhq_development=# EXPLAIN SELECT COUNT(*) FROM audit_events WHERE created_at BETWEEN '2017-01-18' AND '2019-06-01';

 Aggregate  (cost=33.64..33.65 rows=1 width=8)
   ->  Seq Scan on audit_events  (cost=0.00..32.41 rows=494 width=0)
         Filter: ((created_at >= '2017-01-18 00:00:00'::timestamp without time zone) AND (created_at <= '2019-06-01 00:00:00'::timestamp without time zone))
(3 rows)

After:

gitlabhq_development=# EXPLAIN SELECT COUNT(*) FROM audit_events WHERE created_at BETWEEN '2017-01-18' AND '2019-06-01';

 Aggregate  (cost=27.39..27.40 rows=1 width=8)
   ->  Index Only Scan using index_audit_events_on_created_at_and_id on audit_events  (cost=0.27..26.15 rows=494 width=0)
         Index Cond: ((created_at >= '2017-01-18 00:00:00'::timestamp without time zone) AND (created_at <= '2019-06-01 00:00:00'::timestamp without time zone))
(3 rows)

Related: gitlab-com/Product#309 (closed)

Does this MR meet the acceptance criteria?

Conformity

Performance and testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Ash McKenzie

Merge request reports