Skip to content

datastore: Do not use `MATERIALIZED` on Postgres 11

We have recently landed optimizations for queries using the valid_primaries view by using MATERIALIZED views. This keyword is only supported by Postgres 12 and newer though -- and while GitLab officially claims that Postgres 12 is the minimum required version, there are still deployments using Postgres 11 which used to work just fine until now.

Let's use the MATERIALIZED keyword conditionally based on which Postgres version we're running with. In Postgres 11, it's been the default to use MATERIALIZED, so by just omitting it we have effectively the same behaviour as we do have in Postgres 12.

Changelog: fixed

Fixes #3931 (closed) & #3930 (closed)

Edited by Toon Claes

Merge request reports