Rails has an issue with big schemas where it becomes slower over time as the app grows, to fix this issue the schema_cache file was introduced and is enabled by default, it get updated with every migration.
We can create and update the file manually using rake db:schema:cache:dump.
Finally my questions:
- What query does it actually run inside the db?
- Does it lock the db while performing the query?
- Finally is it safe to be ran in production?
Thank you
CodePudding user response:
After logging my DB and running the command, it turns out it just runs
show full fields table_name
against all the tables in the schema.
CodePudding user response:
The command can be executed in production and it creates a db/schema_cache.yml. Mainly it serializes data related to schema into this file. Generally in a prod environment with multiple servers, this file would be shared across to avoid db calls for
show full fields
This query is run by rails framework on boot of servers and with this file the requests would decline and the yml file would serve this.
