Skip to content

WIP: Enable caching of schema.rb

yorickpeterse-staging requested to merge schema-cache into master

What does this MR do?

This enables the caching of schema information as described in http://iempire.ru/2016/12/13/schema-cache/. This means Rails doesn't have to check the schema when booting up. This in turn means we don't have to run expensive queries such as:

SELECT a.attname, format_type(a.atttypid, a.atttypmod), pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = '"milestones"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum;

Such a query can easily take 200 milliseconds on GitLab.com.

Further I observed a reduction of boot timings locally of around 3 seconds, but this may differ per environment.

This was brought to our attention by @stanhu in the #database channel so he really deserves the credit for this.

Does this MR meet the acceptance criteria?

Edited by yorickpeterse-staging

Merge request reports