Tag: postgres

Go, gorm, nested JSON and associations

Go, gorm, nested JSON and associations gorm provides a clean way to store a nested JSON with the relation of associations among tables. The following code creates a DB with three levels of nesting. package main import ( “encoding/json” “fmt” “github.com/jinzhu/gorm” _ “github.com/lib/pq” ) const ( host = “localhost” port = 5432 user = “postgres”…

Mac OS X: role “postgres” does not exist

Install Postgres brew install Postgres Try to log in. $ psql -h localhost -d postgres -U postgres psql: error: could not connect to server: FATAL: role “postgres” does not exist Create the user $ /usr/local/opt/postgres/bin/createuser -s postgres Start the server $ pg_ctl -D /usr/local/var/postgres start pg_ctl: another server might be running; trying to start server…

Design Problems of PostGres- Part II

The problems in PostGres DB are solved in MySQL to an extent. The design merits of MySQL are the following: The primary index has a mapping of key to an offset in the disk. But all secondary index tables have a mapping of key to the primary index’s key. Primary index ——————– | key |…

Design Problems of PostGres- Part I

This post is a quick summary of Why Uber moved from PostGres to MySQL. PostGres Rows and CTID PostGres provides transactions. Transactions need multiple versions of data. So PG is Multi Versioned DB. PG considers each row immutable. Any change to a row creates a new row version. A row is represented as an offset…