gitlab-org--gitlab-foss/db
Andreas Brandl 5b4108f0fd
Replace indexes for counting active users
This adjusts the partial condition for an index. The index is intended
to be used when counting active users with `ghost IS NOT TRUE AND
bot_type IS NULL`.

With the current index, this wasn't working as the partial condition
didn't match the query: `ghost <> TRUE` is not semantically equivalent
to `ghost IS NOT TRUE` (null semantics).

The reason we add an index particularly intended for EE is that the EE
query is going to have the additional part `AND bot_type IS NULL`
whereas the CE query doesn't. Logically, it'd be enough to have an index
for `ghost IS NOT TRUE`. However, on GitLab.com, the query planner makes
poor choices when the additional `AND bot_type IS NULL` part is present:
It goes for the index on `bot_type` and doesn't use the partial index.

Note the existing index isn't being used at all according to GitLab.com
index statistics. Hence we can first remove it and don't have to worry
about the window of time without an index.

Relates to https://gitlab.com/gitlab-org/gitlab-ce/issues/66770
2019-09-02 15:22:32 +02:00
..
fixtures Add production fixture to create project 2019-08-30 16:17:50 +00:00
migrate Replace indexes for counting active users 2019-09-02 15:22:32 +02:00
optional_migrations Add version 4.2 to all existing migrations 2018-11-22 13:18:28 +01:00
post_migrate Rename epic column state to state_id 2019-08-30 11:28:20 +00:00
schema.rb Replace indexes for counting active users 2019-09-02 15:22:32 +02:00
seeds.rb