endpoint_cost
Estimate the number of database queries each endpoint request costs, using page size and nested-fan-out assumptions, to spot N+1 query risks before running tests.
Instructions
How many queries one request to each endpoint will cost.
Every tool that answers this runs the application and tells you afterwards:
the debug toolbar, silk, assertNumQueries. The number is derivable before
anything runs. One query for the page, plus one per object for every
serializer field crossing a relation the view did not prefetch, plus that
again per level of nesting.
On the demo project the same serializer measured 2852 queries behind an
unoptimised queryset and 2 behind an optimised one. The ratio is the
reliable part; the absolute number is only as good as nested_fan_out.
Args:
page_size: objects a list response returns.
nested_fan_out: assumed children per parent one level down. A property
of your data that reading the code cannot reveal.
list_only: skip views that only ever return a single object.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| list_only | No | ||
| page_size | No | ||
| nested_fan_out | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||