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

:on-delete :cascade #698

Merged
merged 11 commits into from
Jan 27, 2025
Merged

:on-delete :cascade #698

merged 11 commits into from
Jan 27, 2025

Conversation

tonsky
Copy link
Contributor

@tonsky tonsky commented Jan 9, 2025

  • Optimize current on-delete impl
  • Transform it into single recursive query
  • Add delete-entity support to client datalog
  • Add option to the explorer
  • Add option to CLI schema file

@tonsky tonsky force-pushed the optimize-cascade-delete branch from 3a084cd to 193d5af Compare January 9, 2025 20:06
Copy link

github-actions bot commented Jan 9, 2025

View Vercel preview at instant-www-js-optimize-cascade-delete-jsv.vercel.app.

@tonsky
Copy link
Contributor Author

tonsky commented Jan 9, 2025

Progress so far:

  • Wrote a bench for recursive delete
  • Optimized delete-entity-multi!

@tonsky tonsky force-pushed the optimize-cascade-delete branch 2 times, most recently from b9f9191 to 0d35b0c Compare January 9, 2025 20:12
@tonsky tonsky force-pushed the optimize-cascade-delete branch from 0d35b0c to 293ab5b Compare January 16, 2025 21:12
server/src/instant/db/transaction.clj Outdated Show resolved Hide resolved
server/src/instant/db/transaction.clj Outdated Show resolved Hide resolved
server/src/instant/db/transaction.clj Show resolved Hide resolved
server/src/instant/db/transaction.clj Outdated Show resolved Hide resolved
server/src/instant/db/transaction.clj Outdated Show resolved Hide resolved
@tonsky tonsky force-pushed the optimize-cascade-delete branch 2 times, most recently from db7d1ee to e2b34a9 Compare January 17, 2025 20:02
@tonsky
Copy link
Contributor Author

tonsky commented Jan 17, 2025

To the best of my abilities, I made cascade expansion as a single query but it still sometimes triggers slow path.

One of the culprits, I think, is [:= [:to_jsonb :entity_id] :value] join. This could be sped up by introducing value_ref column that contains parsed uuid. Might benefit many other places, too, anywhere where we need to follow a reference, in fact.

I left a TODO, maybe plan it as a separate task?

@tonsky tonsky force-pushed the optimize-cascade-delete branch 4 times, most recently from b31a931 to 2d52ce2 Compare January 21, 2025 18:13
@tonsky
Copy link
Contributor Author

tonsky commented Jan 21, 2025

Okay I think store.js support for cascade is in, + tests

@tonsky tonsky force-pushed the optimize-cascade-delete branch 3 times, most recently from 4a11b67 to 61feb5a Compare January 22, 2025 19:07
@tonsky tonsky force-pushed the optimize-cascade-delete branch from 915fb98 to 6705df1 Compare January 24, 2025 19:29
@tonsky tonsky marked this pull request as ready for review January 24, 2025 19:30
@tonsky tonsky force-pushed the optimize-cascade-delete branch from 6705df1 to 4a3ff22 Compare January 24, 2025 19:41
Copy link
Contributor

@dwwoelfel dwwoelfel left a comment

Choose a reason for hiding this comment

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

LGTM!

server/src/instant/db/model/triple.clj Outdated Show resolved Hide resolved
server/src/instant/db/model/triple.clj Outdated Show resolved Hide resolved
server/src/instant/db/transaction.clj Outdated Show resolved Hide resolved
server/src/instant/db/transaction.clj Outdated Show resolved Hide resolved
server/src/instant/db/model/triple.clj Outdated Show resolved Hide resolved
Copy link
Contributor

@stopachka stopachka left a comment

Choose a reason for hiding this comment

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

So cool!

@tonsky tonsky merged commit 9cb9677 into main Jan 27, 2025
27 checks passed
@tonsky tonsky deleted the optimize-cascade-delete branch January 27, 2025 14:59
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.

4 participants