guide icon indicating copy to clipboard operation
guide copied to clipboard

Change Postgres to store data in JSON

Open neongreen opened this issue 6 years ago • 2 comments

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 selectCategories with code compiled with -O on the official database.
  • [ ] Benchmark how long it takes to do updateCategory id on the biggest category with code compiled with -O on 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.

neongreen avatar Aug 23 '19 09:08 neongreen

You can use gauge for benchmarking. Using benchmark suites is inconvenient so just add a new command to the CLI.

neongreen avatar Aug 23 '19 10:08 neongreen

The new command should find the biggest category in the current database and then perform the benchmarks.

neongreen avatar Aug 23 '19 10:08 neongreen