Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refs #1533
This makes a first pass at improving performance via reducing the
number of database queries made by requests to the Posts API. Much of
what's being changed here is "low-hanging fruit" in the form of
applying
prefetch_related
andselect_related
to our initial queryto prevent further queries later.
In my local testing, this definitely reduced the number of queries
performed, and I'd be interested in seeing what the performance looks
like in the production environment before working too much more on
further improving the performance.
I'll note that one big source of additional queries is the
get_content_type
function. Some of these queries, particularly onesrelated to finding a page's wagtail-ancestor and its specific page
type, I am not sure exactly how to prefetch or if they can be (though
it may very well be possible).