-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hybrid properties were the root cause of performance issues with various queries we were trying to run on model receipts. Now we return an SQL aggregate function instead, allowing you to build similar queries without the massive performance hit. This change uses the attendee receipt discrepancies and nonzero balance pages as a proof of concept -- if these become useable once on prod, then we can apply this change to related currently-unusable pages. One important thing to note is that you should NOT ever use the new _sql aggregate functions from two different tables in one query -- this either creates a cartesian join or, if you specify joins, repeats the rows from earlier tables in the join and screws up calculations (e.g., doubling the item total). You can see how we handle needing aggregates from two different tables in the attendees_nonzero_balance page handler, where we create a subquery for the ReceiptItems table. This appears to work well alongside normal aggregate functions/outer joins for ReceiptTransactions. For more information, see https://stackoverflow.com/questions/12484975/sqlalchemy-using-func-with-outerjoin-on-multiple-tables and https://blog.miguelgrinberg.com/post/nested-queries-with-sqlalchemy-orm
- Loading branch information
Showing
6 changed files
with
80 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters