Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
327 stars 208 forks source link

maybe expand the swingstore API to take better advantage of SQLite features #6677

Open warner opened 1 year ago

warner commented 1 year ago

What is the Problem Being Solved?

Now that the kvStore is kept in a SQLite DB (#3087, PR #6561), we could take advantage of SQL to improve or simplify the way the kernel uses the DB. This would expand the swingstore API to add new calls, not just key/value get/set/delete.

This is an exploratory ticket, to brainstorm about things we could do better. cc @FUDCo

On the kernel side, some things we might do include:

On the vat side (e.g. the vatstore), we might:

The "rank order" key encoding we use in virtual collections could be replaced with more sophisticated schemes (e.g. one column for the data type, and if the datatype is bigint, then the second column is digit length, and the third is the actual decimal-encoded value, and we have an INDEX that cites all three columns). Relatedly, we might be able to compile the "pattern" constraint into a more-direct SQL query. OTOH, the speedup is limited to the indices we add to the table, and everything eventually bottoms out into some linear search of a subset of the table. So we'd be treading on the territory of DBAs and their optimization magic, while obscuring the scheme with other layers on top.

Description of the Design

Security Considerations

Test Plan

warner commented 1 year ago

https://github.com/Agoric/agoric-sdk/issues/3087#issuecomment-1283193404 has some more thoughts for what we should do with the new SQL syntax