Skip to content

[Documentation] Document why N+1 Cached queries are considered bad

Problem to solve

The cached queries help with reducing DB load, but they still:

  • consume memory
  • require as to re-instantiate each AR object
  • require as to re-instantiate each relation of the object
  • makes us spend additional CPU-cycles to look into a list of cached queries.

We should treat the CACHE the same as N+1 queries. They are cheaper, but they are not cheap at all from ~memory perspective.

Proposal

We should document why N+1 Cached queries are considered bad form ~memory perspective, and update documentation https://docs.gitlab.com/ee/development/merge_request_performance_guidelines.html#query-counts.

Edited by Nikola Milojevic