guide
guide copied to clipboard
Change Postgres to store data in JSON
Tables (categories, items, traits) should be compressed into a single categories table:
CREATE TABLE categories (
uid text PRIMARY KEY, -- Unique category ID
data jsonb NOT NULL
);
- [x] Change the schema. (No need to write a migration, just change the v0 schema.)
- [x] Implement
selectCategories,selectCategory,insertCategory,updateCategory. - [ ] Benchmark how long it takes to execute
selectCategorieswith code compiled with-Oon the official database. - [ ] Benchmark how long it takes to do
updateCategory idon the biggest category with code compiled with-Oon the official database.
Based on the latter two points we can decide whether we need any fine-grained select/update functions or whether we can get away with simply reading and writing everything all the time.
You can use gauge for benchmarking. Using benchmark suites is inconvenient so just add a new command to the CLI.
The new command should find the biggest category in the current database and then perform the benchmarks.