Closed batpad closed 6 years ago
Documentation to perform eager loading
in Sequelize: http://docs.sequelizejs.com/manual/tutorial/models-usage.html#eager-loading
I think we've done a good job on prefetching and ensuring indexes. This can probably do with another round of inspection later, but nothing immediately actionable. Closing.
We should make sure that the queries generated by Sequelize are as efficient as possible, and hit indexes for any filters:
For all end-points that fetch things or do filters, we should:
Inspect the generated SQL - make sure we are not doing multiple queries where a single query would suffice - need to do a bit of research on how Sequelize handles this, but essentially: say we are fetching a list of items, and for each of the items, want to fetch all the tags -- it should generate all items and all their tags in a single query and NOT make a separate query to fetch tags for each item in the list. Most ORMs have a concept to
prefetch related
or so and we should make sure we use that where appropriate.For all listing / filter end-points, inspect generated SQL and run
EXPLAIN ANALYZE
on the queries in the database to see the query plan for each query, and make sure that wherever possible queries are hitting indexes and not doing full table scans.cc @emilymdubois