icssc / anteater-api

API that provides easy access to public data from UC Irvine. Developed for Anteaters, by Anteaters.
https://anteaterapi.com/reference
GNU Affero General Public License v3.0
3 stars 0 forks source link

perf: optimize courses and instructors routes #23

Closed ecxyzzy closed 1 week ago

ecxyzzy commented 1 week ago

Description

Optimize performance of courses/instructors by using materialized views, where each view is built using a query that performs JSON aggregation on the DBMS.

Also modify the WebSoc scraper to update the materialized view every time it completes a scrape.

How Has This Been Tested?

Benchmarked locally with Postman, see screenshot.

The numbers are an apples-to-apples comparison when tested locally so in production it will definitely be higher, but should still be a pretty significant improvement since we've also cut down on the number of round trips.

Screenshots (if appropriate):

image

Types of changes

Checklist: