Monday, May 30, 2022

Postgres.js

Postgres.js with Rasmus Porsager (JS Party #221) |> Changelog podcast    

Postgres.js –the fastest full-featured PostgreSQL client for Node.js and Deno.
 
// users.js
import sql from './db.js'

async function getUsersOver(age) {
  const users = await sql`
    select
      name,
      age
    from users
    where age > ${ age }
  `
  // users = Result [{ name: "Walter", age: 80 }, { name: 'Murray', age: 68 }, ...]
  return users
}

NewSQL: Vitess (PlanetScale DB), CockroachDB, ...


NewSQL is a class of relational database management systems that seek to provide the scalability of NoSQL systems for online transaction processing (OLTP) workloads while maintaining the ACID guarantees of a traditional database system.



NewSQL — The Next Evolution in Databases | by Gokul Prabagaren | Capital One Tech | Medium

TiDB, CockroachDB, FaunaDB, Vitess (PlanetScale)

"NewSQL promises to combine benefits from RDBMS (strong consistency) with benefits from NoSQL (scalability); it mainly achieves this through new architecture patterns and efficient SQL storage engines.

Most current NewSQL databases are based on Google’s Spanner database and the theories in academic papers such as Calvin: Fast Distributed Transactions for Partitioned Database Systems from Yale. Spanner is Google’s scalable, multi-version, globally-distributed, and synchronously-replicated database. It was the first system to distribute data at global scale and support externally-consistent distributed transactions. The Calvin academic paper from Yale was on leveraging determinism to guarantee active replication and full ACID-compliance of distributed transactions without two-phase commit.

TiDB, CockroachDB, FaunaDB, Vitess are a few of the leading NewSQL databases. Each database implementation has its own take on how to ensure strong consistency with scalable architecture. Let’s dive into them."



interview with PlanetScale CEO, that also worked in GitHub


Based on Vitess created by Google for YouTube MySQL DB sharding, in GoLang
originally running on Borg and now on Kubernetes. 

Interesting innovation: "db branches" with ability to "revert back"

Vitess is a database clustering system for horizontal scaling of MySQL through generalized sharding.


5 GB storage
1 billion row reads/mo
10 million row writes/mo
1 production branch
1 development branch


interesting & useful feature
PlanetScale Rewind - Zero Downtime Reverts

PlanetScale - Crunchbase Company Profile & Funding

PlanetScale builds a database-as-a-service offering on Vitess,
an open source sharding middleware system for MySQL.



Is there a similar service for Postgres DB?



CockroachDB is also written in GoLang, and it supports PostgreSQL