Skip to content

Update raw tables documentation #203

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion usage/use-case-examples/raw-tables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ Also note that raw tables are only supported by the new [Rust-based sync client]

Consider raw tables when you need:

- **Advanced SQLite features** like `FOREIGN KEY` and `ON DELETE CASCADE` constraints
- **Indexes** - PowerSync's default schema has basic support for indexes on columns, while raw tables give you complete control to create indexes on expressions, use `GENERATED` columns, etc
- **Improved performance** for complex queries (e.g., `SELECT SUM(value) FROM transactions`) - raw tables more efficiently get these values directly from the SQLite column, instead of extracting the value from the JSON object on every row
- **Reduced storage overhead** - eliminate JSON object overhead for each row in `ps_data__<table>.data` column
- **To manually create tables** - Sometimes you need full control over table creation, for example when implementing custom triggers

<Warning>
**Advanced SQLite features** like `FOREIGN KEY` and `ON DELETE CASCADE` constraints may need special handling. If your use case requires these features, please reach out to us for guidance and potential workarounds.
</Warning>

## How Raw Tables Work

### Current JSON-Based System
Expand Down