Skip to content

Improve performance of row ids #180

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Improve performance of row ids #180

wants to merge 5 commits into from

Conversation

jsdt
Copy link
Contributor

@jsdt jsdt commented Apr 25, 2025

Description of Changes

This makes a few performance improvements. It is pretty similar to #179. The key changes are:

  • This updates how rowIds are created. For tables with a primary key, it is the primary key value. Otherwise it is a base64 encoding of the whole row. Previously the rowId was always a string representation of the entire row, even if we had a primary key.
  • This gets rid of the very slow OperationsMap, replacing it with a standard Map. This is done by defining a way to turn any AlgebraicValue into a primitive that can be used as a Map key. This conversion is basically free for any primary keys, since they have primitive values.

This also has the fix of using concat instead of push(... that was in #179.

Since I was already making some changes in the TableCache, I added some more context to log messages, so hopefully any future bug reports will be easier to look into.

These changes also give us a way to make find efficient, but I didn't put it in this PR.

Requires SpacetimeDB PRs

Requires this codegen change clockworklabs/SpacetimeDB#2671, so we need to wait for the next release.

Testing

This has some coverage in unit tests, and has some manual testing with the quickstart, but more testing should be added before merging.

Copy link

changeset-bot bot commented Apr 25, 2025

⚠️ No Changeset found

Latest commit: 5534ace

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

pkg-pr-new bot commented Apr 25, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@clockworklabs/spacetimedb-sdk@180

commit: 4ca7a04

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.

1 participant