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

perf: smarter transactions and authorization for built-in actions #1347

Merged
merged 6 commits into from
Jan 5, 2024

Conversation

davenewza
Copy link
Contributor

@davenewza davenewza commented Jan 5, 2024

Performance improvements on built-in actions

Summary:

  • create: reduced from 5 to 2 - 5 db hits
  • update: reduced from 6 to 2 - 4 db hits
  • delete: reduced from 6 to 2 - 4 db hits

Smarter authorization

For all action types, we perform better early authorization checks, which means we can avoid unnecessary database hits when row-based permissions aren't being used. For create, we even avoid the use of transactions entirely.

Typically, this is the order of database events (i.e. incurring a DB 'hit') for an built-in create action:
a) open transaction
b) execute create statement
c) perform row-based permissions query
d) commit (or rollback) transaction

That is FOUR hits to the database, which is expensive especially when no row-based permissions are even performed.

Now we check if transaction and row-based permission checks are even needed. If they aren't needed, then the action will be reduced to a single query - executing the insert statement without a transaction block

No more transactions on update and delete

Furthermore, transactions were only in place on update and delete as a fail safe if multiple rows happened to be affected (which would be an error on Keel's part). We have so many tests and I think the risk of this happening is so low. The cost of a transaction for every single action call is quite high, so I've opted for dropping it.

@davenewza davenewza requested a review from a team January 5, 2024 06:52
@davenewza davenewza merged commit f27a753 into main Jan 5, 2024
10 checks passed
@davenewza davenewza deleted the perf/smart-action-transactions branch January 5, 2024 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants