The Distributed SQL Blog

Thoughts on distributed databases, open source, and cloud native

A SQL Stopwatch Utility for YugabyteDB or PostgreSQL as an Alternative for “\timing on”

This blog post shows you a few ways to use SQL to implement a timer for any multi-statement operation for use with ysqlsh with YugabyteDB (or psql with PostgreSQL). These tools are the overwhelmingly common choice for all sorts of ad hoc tasks as well as for critical tasks like running installation scripts. The native \timing on” feature times only individual SQL statements.

Read More

Using the PostgreSQL Recursive CTE – Part Two

Computing Bacon Numbers for actors listed in the IMDb

YugabyteDB is an open source, high-performance distributed SQL database built on a scalable and fault-tolerant design inspired by Google Spanner. YugabyteDB uses its own special distributed document store called DocDB. But it provides SQL and stored procedure functionality by re-using the “upper half” of the standard PostgreSQL source code.

Read More

Using the PostgreSQL Recursive CTE – Part One

Traversing an employee hierarchy

YugabyteDB is an open source, high-performance distributed SQL database built on a scalable and fault-tolerant design inspired by Google Spanner. YugabyteDB uses its own special distributed document store called DocDB. But it provides SQL and stored procedure functionality by re-using the “upper half” of the standard PostgreSQL source code. This is explained in the two part blog post “Distributed PostgreSQL on a Google Spanner Architecture”: (1) Storage Layer;

Read More

Using PostgreSQL Aggregate Functions in YugabyteDB to Analyze COVID-19 Data

YugabyteDB is an open source, high-performance distributed SQL database built on a scalable and fault-tolerant design inspired by Google Spanner. YugabyteDB uses its own special distributed document store called DocDB. But it provides SQL and stored procedure functionality by re-using the “upper half” of the standard PostgreSQL source code. This is explained in the two part blog post “Distributed PostgreSQL on a Google Spanner Architecture”: (1) Storage Layer;

Read More

Polymorphism in SQL part two – variadic functions

YugabyteDB is an open source, high-performance distributed SQL database built on a scalable and fault-tolerant design inspired by Google Spanner. YugabyteDB uses its own special distributed document store called DocDB. But it provides SQL and stored procedure functionality by re-using the “upper half” of the standard PostgreSQL source code. This is explained in the two part blog post “Distributed PostgreSQL on a Google Spanner Architecture”: (1) Storage Layer;

Read More

Polymorphism in SQL part one – anyelement and anyarray

The term “polymorphism”, and its inflections, has various meanings in the context of programming languages in general. Roughly, it means “chameleon-like”. Of course, Wikipedia has something to say about it, here. PostgreSQL uses it with this meaning: “Parametric polymorphism: when one or more types are not specified by name but by… symbols that can represent any type”.

Read More

Follow-up: Postgres Conference Webinar – Introduction to YugabyteDB

I delivered the webinar “YugabyteDB: a distributed PostgreSQL database” last week. It was hosted by Postgres Conference in a series that they’d arranged so that the speakers who’d been selected to speak at their big annual conference in New York City in March could reach their audience. COVID-19 brought that event’s cancellation. This brief post tells you where you can find the edited videorecording and the PDF version of the slides that I used.

Read More

Document Data Modeling in YugabyteDB with the JSON Data Types

YugabyteDB has two JSON data types, json and jsonb, to let you store documents in a column in a YSQL table and to do content-based queries with index support. YSQL is PostgreSQL compatible and it therefore supports every one of the rich set of about thirty five JSON-specific operators and functions that users of PostgreSQL’s JSON functionality might already know,

Read More

Four Compelling Use Cases for PostgreSQL Table Functions

Welcome to part three of a three-part series of posts on PostgreSQL’s table functions. These functions can be easily leveraged in a distributed SQL database like YugabyteDB, which is PostgreSQL compatible.

In this final post, I’ll discuss four realistic use cases that call for user-defined table functions and I’ll explain how each case is met using complete,

Read More