Skip to content

Commit

Permalink
🐌 Fix performance regression causing Purdue.io front-end timeouts (#67)
Browse files Browse the repository at this point in the history
Recently the Purdue.io front-end started showing timeouts when browsing
the Class list page for a particular Course.

Investigation revealed expensive SQL queries being generated, taking
upwards of a minute to complete. Analysis revealed this section was
contributing most of the cost of the query, requiring sequential
evaluation of rows from disk:
```sql
SELECT t8."Id", t8."Email", t8."Name", t8."MeetingId", t8."InstructorId"
FROM (
	SELECT i."Id", i."Email", i."Name", m0."MeetingId", m0."InstructorId", ROW_NUMBER() OVER(PARTITION BY m0."MeetingId" ORDER BY i."Id") AS row
	FROM "MeetingInstructor" AS m0
	INNER JOIN "Instructors" AS i ON m0."InstructorId" = i."Id"
) AS t8
WHERE t8.row <= $7
```

Further investigation revealed that this was due to pagination logic
being applied to the `$expand` operation. An issue is open with a
similar repro here: OData/AspNetCoreOData#1041

The pagination logic was being applied due to the recent change #65.
This PR reverts that change to fix the performance regression until a
workaround is provided by the OData library.
  • Loading branch information
haydenmc authored Apr 28, 2024
1 parent 2b07699 commit dd6bfc7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Api/EdmModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ private static StructuralTypeConfiguration<T> GenerateEntitySet<T>(
.Count()
.Expand(MAX_EXPAND_DEPTH)
.OrderBy()
.Page(MAX_RESULTS, MAX_RESULTS)
// .Page(MAX_RESULTS, MAX_RESULTS) // Adding pagination introduces performance
// problems on expand queries.
// https://github.com/OData/AspNetCoreOData/issues/1041
.Select();
}
}
Expand Down

0 comments on commit dd6bfc7

Please sign in to comment.