8 thoughts on “How to simulate production locally?”

  1. I’d suggest to use “EXPLAIN ANALYZE” on the actual query on production database and then use same on your new query. You can get query on rails console using “.to_sql”

    Reply
  2. If you believe it‘s an n+1 issue, you can fix that first and deploy it just because it‘s better than keeping it anyway. If it fixes the slow query, even better.

    Reply
  3. Don’t fix request timeout, fix n+1 queries. Time spent in database depends on mutitude of things, including data volume, load, network latency, machine on which database is run etc. The number of generated queries will be the same on any environment.

    So, just list the queries run within a given request and make sure you’re not affected by the n+1 leak.

    Reply

Leave a Comment