-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimise publication crosslinks #739
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
); | ||
} | ||
|
||
const conditionalWhereTo = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if all this conditional stuff lends to stored procedures being a better solution? This is quite difficult to read and follow. I've had a similar style of query in a project I worked on in the past, it was a bit of a nightmare trying to build the query up to test it outside of the api.
The purpose of this PR was to optimise the slowest query I could find in octopus. This was the full text filtering part of the
getPublicationCrosslinks
function. I looked into what prisma was doing in SQL and attempted to improve it. The main improvement is using a union to collect all the crosslinks (to and from a publication, as they can be either way) into one group.This results in fewer queries:
I collected some timings to see if it was an improvement in speed. I tested each case 5 times and collected an average before working out the difference between the new method's average time and the old method's average time. The margins are quite low because the seed data is not massive, but the new method is consistently quicker (times in ms):
On average across these 4 tests:
Checklist:
Tests:
API
E2E