Skip to content
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

More performance enhancements #1850

Merged
merged 12 commits into from
Dec 9, 2024

Conversation

seeker25
Copy link
Collaborator

@seeker25 seeker25 commented Dec 8, 2024

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the sbc-pay license (Apache 2.0).

@seeker25
Copy link
Collaborator Author

seeker25 commented Dec 8, 2024

@Jxio Looks like you're right about the counts (this is executed on production in OCP):

Probably need to talk to Ethan and John about removing them if they want some serious performance.

With count:
image

Without count:
image

@@ -320,7 +331,7 @@ def search_purchase_history( # noqa:E501; pylint:disable=too-many-arguments, to
count_future = executor.submit(cls.get_count, auth_account_id, search_filter)
sub_query = cls.generate_subquery(auth_account_id, search_filter, limit, page)
query = query.filter(Invoice.id.in_(sub_query.subquery().select())).order_by(Invoice.id.desc())
result_future = executor.submit(db.session.query(Invoice).from_statement(query).all)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was no good, would get rid of all of nice load_only all the rows would have to be reloaded at serialization

.outerjoin(PaymentLineItem, PaymentLineItem.invoice_id == Invoice.id)
.outerjoin(
db.session.query(Invoice)
.join(PaymentAccount, Invoice.payment_account_id == PaymentAccount.id)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joins make sense for these, they will always occur

@seeker25 seeker25 changed the title Add in more conditional joins More performance enhancements Dec 8, 2024
@seeker25
Copy link
Collaborator Author

seeker25 commented Dec 8, 2024

For Monday:

Needs quick side by side comparison
Pay Jobs CI fixed

@seeker25 seeker25 merged commit 8c1dd70 into bcgov:main Dec 9, 2024
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants