Optimize unrenderable content size query #12966
Labels
APP: Device
Re: Device App (content import/export, facility-syncing, user permissions, etc.)
DEV: backend
Python, databases, networking, filesystem...
TAG: cloud
Issues specific to running Kolibri in a cloud environment
TAG: performance
User-facing performance
Observed behavior
When importing or managing a channel, a couple of queries are run to determine the total file content size. In order to achieve that, the calculation needs account for content nodes that have files with presets that are not supported. The resulting query runs poorly for a channel with large amounts of content, like one that has 30GB of resources. Below is a snippet of the resulting query.
Query plan (partial)
Expected behavior
The query should be optimized to reduce its complexity and streamline performance. For example, the following is a first pass at optimizing the query and reduces its complexity, but further optimization of the query and possibly how the total size is calculated could be further improved.
Care should be taken in regards to how the presets are used with the query. The origin of the presets comes from dynamic logic that determines what presets are supported by the Kolibri plugins that are enabled (see
renderable_contentnodes_without_topics_q_filter
). There could be other important queries that rely on how those are prepared as Django queryset filters.User-facing consequences
Requests to import or manage a large channel can encounter timeouts, and the user encounters the screen "Sorry! Something went wrong". In cloud environments, timeouts are important in managing request load and attention should be given to optimizing the app prior to increasing timeouts.
Steps to reproduce
Attempt to import a large channel, like one with 30GB of resources, while using Kolibri configured with postgresql and minimal resources given to the database (1 CPU and 4GB of RAM)
Context
Kolibri 0.17.5
w/ PostgreSQL v13
(BCK)
The text was updated successfully, but these errors were encountered: