PostgreSQL 17’s JSON_TABLE isn’t Particularly Powerful

Exploring practical differences between JSONB and JSON_TABLE in PostgreSQL 17

Chunting Wu
4 min readOct 7, 2024
My girl

Recently Postgres 17 was released, and one of the features interesting to me was the JSON_TABLE keyword. Postgres has always had an ambition to dominate the database market, and of course that includes document databases.

After the release of JSONB support in previous versions of Postgres, this time JSON structures have been made more descriptive. I was expecting a lot of groundbreaking, but JSON_TABLE looks a bit "ordinary". In my opinion, JSON_TABLE just provides syntactic sugar, not much difference in usage.

Let’s take a quick look at some examples to get a feel for the difference between JSON_TABLE and the JSONB of the past.

Preparation

Let’s start by creating a table. In order to be as close to the document database as possible, we’ll use a single JSONB column to store all the order data, including the order item and the customer.

CREATE TABLE orders (
id serial PRIMARY KEY,
order_data JSONB
);

Then we put in two orders, each with two items.

INSERT INTO orders (order_data) VALUES
('{
"items": [
{ "name": "Laptop", "price"…

--

--

Chunting Wu

Architect at SHOPLINE. Experienced in system design, backend development, and data engineering.