Discovery - N+1 Query for search facets in Course Discovery

Description

NewRelic link

New Relic Link for new N+1 query on 1/14/19

I don't think this is an N+1, but it is a transaction that had a memcached get take 40s: New Relic Link

Somewhere in our haystack facet serializer we are making an N+1 call which recently resulted in 1000+ unnecessary DB hits which ended up degrading overall performance of the discovery service (and consequently the edx-mktg site as well)

The view in question is course-discovery/course_discovery/apps/edx_catalog_extensions/api/serializers.py:10

After a brief triage of this issue it is not apparent exactly where we need to add code to the query (select_related or prefetch_related) to prevent this N+1

There are also performance degradations in the top 3 slowest views that we don't have a lot of visibility into. 8+ seconds in the view layer. Adding key transactions here will give us more insight into how to fix.

Acceptance Criteria

  • Add key transactions to the top three slowest discovery views

  • Investigate removing haystack from facet views and querying elasticsearch directly

Steps to Reproduce

None

Story Points

None

Assignee

Jason Myatt

Reporter

Jason Myatt

Reach

None

Impact

None

Platform Area

None

Customer

None

Partner Manager

None

URL

None

Contributor Name

None

Groups with Read-Only Access

None

Actual Points

None

Category of Work

None

Platform Map Area (Levels 1 & 2)

None

Platform Map Area (Levels 3 & 4)

None

Priority

CAT-3
Configure