Skip to content

Draft: Create a partial TestCase index to help Job Errors page performance

Rémi Duraffort requested to merge job-errors-partial-index into master

This index contains only TestCases that passed the metadata string comparison test. This eliminates the need to scan metadata every time the page is loaded.

However, this means that the index has to be updated every time the Job Errors query is changed.

In the commit 927b09f4 the string matching was changed from regex to LIKE. However, it looks like Django fails to emit proper SQL when creating the partial index with LIKE method. (it emits double %% percent signs) Reverting to regex might cause a slightly worse performance but having and index completely compesates that.

Also change the Job Errors page sorting. The previous suite__job__id DESC sorting had to load all the entries to memory before sorting because it was sorted on key in a different table. New sorting uses the TestSuite primary key in descending order which the new index is ordered by from the TestCase perspective.

Subquery is no longer necessary. The by using filter() with cross relation filter it is possible to create the joins of TestJob on TestSuite on TestCase. The metadata can then be obtained using the F expression combined with ExpressionWrapper.

Edited by Igor Ponomarev

Merge request reports