add remove split language chart show hidden hide
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
CREATE TABLE
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE TABLE
CREATE INDEX
CREATE INDEX
CREATE INDEX
CREATE TABLE
CREATE INDEX
INSERT 0 4
INSERT 0 2
INSERT 0 2
INSERT 0 4
INSERT 0 3
INSERT 0 4
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
CREATE FUNCTION
name phone city name quantity
Client One +49 30 1111111 Berlin Laptop 1
Client One +49 30 1111111 Berlin Mouse 2
SELECT 2
QUERY PLAN
Nested Loop (cost=4.96..31.97 rows=4 width=132)
  -> Nested Loop (cost=4.81..31.45 rows=2 width=108)
        -> Nested Loop (cost=4.66..31.05 rows=2 width=84)
              -> Nested Loop (cost=0.45..16.60 rows=1 width=80)
                    Join Filter: (document.client_id = profile.client_id)
                    -> Nested Loop (cost=0.30..16.36 rows=1 width=56)
                          -> Index Scan using document_doc_number_key on document (cost=0.15..8.17 rows=1 width=24)
                                Index Cond: (doc_number = 'DOC-1'::text)
                          -> Index Scan using address_id_profile_id_key on address (cost=0.15..8.17 rows=1 width=48)
                                Index Cond: ((id = document.delivery_address_id) AND (profile_id = document.client_id))
                    -> Index Scan using profile_client_id_key on profile (cost=0.15..0.23 rows=1 width=48)
                          Index Cond: (client_id = address.profile_id)
              -> Bitmap Heap Scan on document_item (cost=4.21..14.37 rows=8 width=20)
                    Recheck Cond: (document.id = document_id)
                    -> Bitmap Index Scan on document_item_pkey (cost=0.00..4.21 rows=8 width=0)
                          Index Cond: (document_id = document.id)
        -> Index Scan using item_pkey on item (cost=0.15..0.20 rows=1 width=40)
              Index Cond: (id = document_item.item_id)
  -> Index Scan using profile_detail_pkey on profile_detail (cost=0.15..0.26 rows=1 width=40)
        Index Cond: (profile_id = profile.id)
EXPLAIN
QUERY PLAN
Nested Loop (cost=4.96..31.97 rows=4 width=132)
  -> Nested Loop (cost=4.81..31.45 rows=2 width=108)
        -> Nested Loop (cost=4.66..31.05 rows=2 width=84)
              -> Nested Loop (cost=0.45..16.60 rows=1 width=80)
                    Join Filter: (d.client_id = p.client_id)
                    -> Nested Loop (cost=0.30..16.36 rows=1 width=56)
                          -> Index Scan using document_doc_number_key on document d (cost=0.15..8.17 rows=1 width=24)
                                Index Cond: (doc_number = 'DOC-1'::text)
                          -> Index Scan using address_id_profile_id_key on address a (cost=0.15..8.17 rows=1 width=48)
                                Index Cond: ((id = d.delivery_address_id) AND (profile_id = d.client_id))
                    -> Index Scan using profile_client_id_key on profile p (cost=0.15..0.23 rows=1 width=48)
                          Index Cond: (client_id = a.profile_id)
              -> Bitmap Heap Scan on document_item di (cost=4.21..14.37 rows=8 width=20)
                    Recheck Cond: (d.id = document_id)
                    -> Bitmap Index Scan on document_item_pkey (cost=0.00..4.21 rows=8 width=0)
                          Index Cond: (document_id = d.id)
        -> Index Scan using item_pkey on item i (cost=0.15..0.20 rows=1 width=40)
              Index Cond: (id = di.item_id)
  -> Index Scan using profile_detail_pkey on profile_detail pd (cost=0.15..0.26 rows=1 width=40)
        Index Cond: (profile_id = p.id)
EXPLAIN
doc_number client_name manager_name
DOC-1 Client One Manager
DOC-2 Client One null
DOC-3 Client Two Manager
SELECT 3
doc_number city street
DOC-1 Berlin Alexanderplatz 1
DOC-3 Paris Rue de Rivoli 2
SELECT 2
doc_number id email name type client_id manager_id created_at
DOC-1 1 c1@x.io Client One client 1 null 2026-08-07 13:36:13.28402+00
DOC-2 1 c1@x.io Client One client 1 null 2026-08-07 13:36:13.28402+00
DOC-3 2 c2@x.io Client Two client 2 null 2026-08-07 13:36:13.28402+00
SELECT 3
name
Client Three
SELECT 1