Skip to content

Set PostgreSQL "random_page_cost" to 2 instead of 4

When digging into queries for https://gitlab.com/gitlab-org/gitlab-ce/issues/30472 our DB consultant and I ran into the issue where an index was not being used, despite that it should be used. The DB consultant found out our random_page_cost is set to 4, and that changing it to 2 resulted in:

  1. PostgreSQL using the index
  2. The query becoming about 4x faster (though we went from 16ms to 4ms, so not all that much)

We should investigate changing this value and monitor the impact.