Skip to content

Conversation

@bean1352
Copy link
Contributor

@bean1352 bean1352 commented Nov 6, 2025

Added "Understanding The SQLite Database" documentation page with instructions for accessing, inspecting, and optimizing PowerSync database files.

Get the SQLite file

  • Android: Single-command database export with customizable download path
  • iOS: Simulator database location finder
  • Web: OPFS export script and explanation of why IndexedDB databases can't be directly downloaded

Inspecting the SQLite file

  • Instructions for opening database using sqlite3 CLI and merging WAL file
  • dbstat query for analyzing table storage usage
  • Breakdown of PowerSync database size

Reducing the SQLite file size

  • VACUUM command usage
  • Page size optimization options

@bean1352 bean1352 requested review from benitav and rkistner November 6, 2025 10:03
Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

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

Looks good overall

<Tab title="Android">
Ensure your emulator is running, then replace `com.package-name` with your application's package name, `your-db-name.sqlite` with your database file name, and `~/Desktop/your-db-name.sqlite` with your desired download path.
```shell
adb exec-out run-as com.package-name cat databases/your-db-name.sqlite > ~/Desktop/your-db-name.sqlite
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Use adb pull rather than cat.
  2. Also include the WAL file, otherwise recent changes will be lost.

I'd also recommend just using the local dir instead of ~/Desktop, just to simplify the instructions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am having a difficult time dealing with permissions when using adb pull.

  1. Why is it better than using cat?
  2. Are the permission issues likely just something on my side?

Copy link
Contributor

Choose a reason for hiding this comment

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

You may need the same run-as structure with pull.

If that turns out to tricky, cat could work. The main issues I see with that:

  1. It probably doesn't work on windows (powershell).
  2. If you get the > part wrong, it can completely mess up your terminal

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I see run-as with cat is basically the recommended solution for the permissions issue - I guess we can keep that.


The `VACUUM` command reclaims unused space in the database:

```sql
Copy link
Collaborator

Choose a reason for hiding this comment

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

@bean1352 in your experience are you comfortable that users will know they need to wrap this in a db.execute() call, or should we point that out?

great PR btw, very overdue!

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