sary Developer

PostgreSQL

Tables

cafes13 rows

cafes columns
ColumnTypeNullDefault
idintegerno
display_nametextno
official_nametextno
name_jatextyes
prefecturetextno
citytextno
areatextno
nearest_stationtextyes
kindtextno
statustextno
morning_servicebooleanyes
urltextyes
source_urltextno
confidencetextno
  • PRIMARY KEYcafes_pkey(id)
  • CHECKcafes_status_check(status IN ('open', 'closed', 'uncertain'))

curry_shops3 rows

curry_shops columns
ColumnTypeNullDefault
idintegerno
display_nametextno
official_nametextno
name_jatextyes
prefecturetextno
citytextno
areatextno
nearest_stationtextyes
kindtextno
statustextno
urltextyes
source_urltextno
confidencetextno
  • PRIMARY KEYcurry_shops_pkey(id)
  • CHECKcurry_shops_status_check(status IN ('open', 'closed', 'uncertain'))

izakaya1 row

izakaya columns
ColumnTypeNullDefault
idintegerno
display_nametextno
official_nametextno
name_jatextyes
prefecturetextno
citytextno
areatextno
nearest_stationtextyes
kindtextno
statustextno
urltextyes
source_urltextno
confidencetextno
  • PRIMARY KEYizakaya_pkey(id)
  • CHECKizakaya_status_check(status IN ('open', 'closed', 'uncertain'))

photos0 rows

photos columns
ColumnTypeNullDefault
idtextno
categorytextno
srctextno
widthintegerno
heightintegerno
taken_atdateyes
captiontextno''::text
alttextno
  • PRIMARY KEYphotos_pkey(id)
  • CHECKphotos_category_check(category IN ('coffee', 'curry', 'izakaya'))
  • CHECKphotos_height_check(height > 0)
  • CHECKphotos_width_check(width > 0)

journal0 rows

journal columns
ColumnTypeNullDefault
slugtextno
titletextno
langtextno
like_slugtextyes
published_attimestamp with time zoneno
bodytextno
content_hashtextno
  • PRIMARY KEYjournal_pkey(slug)
  • CHECKjournal_lang_check(lang IN ('ja', 'en'))
  • CHECKjournal_slug_check(slug ~ '^[a-z0-9]+(-[a-z0-9]+)*$')

Queries

PostgreSQL 17.0 (TiDB Cloud Starter with PostgreSQL compatibility. 20261201-0dbe462)

Open cafes per city

SELECT city, count(*) AS cafes FROM cafes WHERE status = 'open' GROUP BY city ORDER BY cafes DESC, city
Open cafes per city, result
citycafes
Nagoya8
Gifu1
Koto1
Nagakute1
Shibuya1
EXPLAIN
Sort  (cost=184.10..184.10 rows=33 width=80)
  Sort Key: cafes DESC, city
  ->  HashAggregate  (cost=14.33..17.63 rows=33 width=80)
        Group Key: city
        ->  Seq Scan on cafes  (cost=0.00..14.33 rows=333 width=560)
              Filter: (status = 'open'::text)
EXPLAIN ANALYZE
Sort  (cost=184.10..184.10 rows=33 width=80)
  Sort Key: cafes DESC, city
  ->  HashAggregate  (cost=14.33..17.63 rows=33 width=80)
        Group Key: city
        ->  Seq Scan on cafes  (cost=0.00..14.33 rows=333 width=560)
              Filter: (status = 'open'::text)
Actual Rows: 5
Execution Time: 1.178 ms
Catalog Descriptor Loads: 0
Catalog Descriptor Hits: 2
Catalog Invocation Point Loads: 0
Catalog Invocation Point Hits: 0
Catalog Invocation Batch Loads: 0
Catalog Invocation Batch Keys: 0
Catalog Invocation Batch Hits: 0
Catalog Routine Inventory Loads: 0
KV Table Scan Pairs: 13
KV Table Scan Requests: 1
KV Index Scan Pairs: 0
KV Batch Get Keys: 0
KV Batch Get Calls: 0
KV Eager Mutation Submissions: 0
Catalog Relation Inventory Loads: 0
Catalog Type Lookups: 0
Catalog Type Inventory Loads: 0
Planner Build Logical Calls: 1
Planner Prepare Contexts Calls: 1
Planner Optimize Logical Calls: 1
Catalog Descriptor Loads
0
Catalog Descriptor Hits
2
Catalog Invocation Point Loads
0
Catalog Invocation Point Hits
0
Catalog Invocation Batch Loads
0
Catalog Invocation Batch Keys
0
Catalog Invocation Batch Hits
0
Catalog Routine Inventory Loads
0
KV Table Scan Pairs
13
KV Table Scan Requests
1
KV Index Scan Pairs
0
KV Batch Get Keys
0
KV Batch Get Calls
0
KV Eager Mutation Submissions
0
Catalog Relation Inventory Loads
0
Catalog Type Lookups
0
Catalog Type Inventory Loads
0
Planner Build Logical Calls
1
Planner Prepare Contexts Calls
1
Planner Optimize Logical Calls
1

Cafes with morning service

SELECT display_name, area FROM cafes WHERE morning_service IS TRUE ORDER BY display_name
Cafes with morning service, result
display_namearea
SILVIAKarayama-cho
EXPLAIN
Sort  (cost=2804.66..2804.66 rows=333 width=560)
  Sort Key: display_name
  ->  Seq Scan on cafes  (cost=0.00..14.33 rows=333 width=560)
        Filter: (morning_service IS TRUE)
EXPLAIN ANALYZE
Sort  (cost=2804.66..2804.66 rows=333 width=560)
  Sort Key: display_name
  ->  Seq Scan on cafes  (cost=0.00..14.33 rows=333 width=560)
        Filter: (morning_service IS TRUE)
Actual Rows: 1
Execution Time: 2.921 ms
Catalog Descriptor Loads: 0
Catalog Descriptor Hits: 2
Catalog Invocation Point Loads: 0
Catalog Invocation Point Hits: 0
Catalog Invocation Batch Loads: 0
Catalog Invocation Batch Keys: 0
Catalog Invocation Batch Hits: 0
Catalog Routine Inventory Loads: 0
KV Table Scan Pairs: 13
KV Table Scan Requests: 1
KV Index Scan Pairs: 0
KV Batch Get Keys: 0
KV Batch Get Calls: 0
KV Eager Mutation Submissions: 0
Catalog Relation Inventory Loads: 0
Catalog Type Lookups: 0
Catalog Type Inventory Loads: 0
Planner Build Logical Calls: 1
Planner Prepare Contexts Calls: 1
Planner Optimize Logical Calls: 1
Catalog Descriptor Loads
0
Catalog Descriptor Hits
2
Catalog Invocation Point Loads
0
Catalog Invocation Point Hits
0
Catalog Invocation Batch Loads
0
Catalog Invocation Batch Keys
0
Catalog Invocation Batch Hits
0
Catalog Routine Inventory Loads
0
KV Table Scan Pairs
13
KV Table Scan Requests
1
KV Index Scan Pairs
0
KV Batch Get Keys
0
KV Batch Get Calls
0
KV Eager Mutation Submissions
0
Catalog Relation Inventory Loads
0
Catalog Type Lookups
0
Catalog Type Inventory Loads
0
Planner Build Logical Calls
1
Planner Prepare Contexts Calls
1
Planner Optimize Logical Calls
1

One cafe by id

SELECT display_name, area, kind FROM cafes WHERE id = 1
One cafe by id, result
display_nameareakind
Q.O.L.COFFEEMarunouchiroaster + specialty coffee shop
EXPLAIN
Index Scan using cafes_pkey on cafes  (cost=0.00..1.50 rows=1 width=560)
  Index Cond: (id = 1)
EXPLAIN ANALYZE
Index Scan using cafes_pkey on cafes  (cost=0.00..1.50 rows=1 width=560)
  Index Cond: (id = 1)
Actual Rows: 1
Execution Time: 0.936 ms
Catalog Descriptor Loads: 0
Catalog Descriptor Hits: 2
Catalog Invocation Point Loads: 0
Catalog Invocation Point Hits: 0
Catalog Invocation Batch Loads: 0
Catalog Invocation Batch Keys: 0
Catalog Invocation Batch Hits: 0
Catalog Routine Inventory Loads: 0
KV Table Scan Pairs: 0
KV Table Scan Requests: 0
KV Index Scan Pairs: 0
KV Batch Get Keys: 0
KV Batch Get Calls: 0
KV Eager Mutation Submissions: 0
Catalog Relation Inventory Loads: 0
Catalog Type Lookups: 0
Catalog Type Inventory Loads: 0
Planner Build Logical Calls: 1
Planner Prepare Contexts Calls: 1
Planner Optimize Logical Calls: 1
Catalog Descriptor Loads
0
Catalog Descriptor Hits
2
Catalog Invocation Point Loads
0
Catalog Invocation Point Hits
0
Catalog Invocation Batch Loads
0
Catalog Invocation Batch Keys
0
Catalog Invocation Batch Hits
0
Catalog Routine Inventory Loads
0
KV Table Scan Pairs
0
KV Table Scan Requests
0
KV Index Scan Pairs
0
KV Batch Get Keys
0
KV Batch Get Calls
0
KV Eager Mutation Submissions
0
Catalog Relation Inventory Loads
0
Catalog Type Lookups
0
Catalog Type Inventory Loads
0
Planner Build Logical Calls
1
Planner Prepare Contexts Calls
1
Planner Optimize Logical Calls
1

Curry shops and izakaya

SELECT 'curry' AS list, display_name, status FROM curry_shops UNION ALL SELECT 'izakaya', display_name, status FROM izakaya ORDER BY 1, 2
Curry shops and izakaya, result
listdisplay_namestatus
curryTrippin' Curryclosed
currychikakuopen
currytoiopen
izakayaTeppanyaki Ichitoraopen
EXPLAIN
Sort  (cost=21975.57..21975.57 rows=2000 width=120)
  Sort Key: list, display_name
  ->  Nested Loop SetOperation  (cost=0.00..44.00 rows=2000 width=120)
            Seq Scan on curry_shops  (cost=0.00..11.00 rows=1000 width=520)
        ->  Seq Scan on izakaya  (cost=0.00..11.00 rows=1000 width=520)
EXPLAIN ANALYZE
Sort  (cost=21975.57..21975.57 rows=2000 width=120)
  Sort Key: list, display_name
  ->  Nested Loop SetOperation  (cost=0.00..44.00 rows=2000 width=120)
            Seq Scan on curry_shops  (cost=0.00..11.00 rows=1000 width=520)
        ->  Seq Scan on izakaya  (cost=0.00..11.00 rows=1000 width=520)
Actual Rows: 4
Execution Time: 2.045 ms
Catalog Descriptor Loads: 0
Catalog Descriptor Hits: 4
Catalog Invocation Point Loads: 0
Catalog Invocation Point Hits: 0
Catalog Invocation Batch Loads: 0
Catalog Invocation Batch Keys: 0
Catalog Invocation Batch Hits: 0
Catalog Routine Inventory Loads: 0
KV Table Scan Pairs: 4
KV Table Scan Requests: 2
KV Index Scan Pairs: 0
KV Batch Get Keys: 0
KV Batch Get Calls: 0
KV Eager Mutation Submissions: 0
Catalog Relation Inventory Loads: 0
Catalog Type Lookups: 0
Catalog Type Inventory Loads: 0
Planner Build Logical Calls: 1
Planner Prepare Contexts Calls: 1
Planner Optimize Logical Calls: 1
Catalog Descriptor Loads
0
Catalog Descriptor Hits
4
Catalog Invocation Point Loads
0
Catalog Invocation Point Hits
0
Catalog Invocation Batch Loads
0
Catalog Invocation Batch Keys
0
Catalog Invocation Batch Hits
0
Catalog Routine Inventory Loads
0
KV Table Scan Pairs
4
KV Table Scan Requests
2
KV Index Scan Pairs
0
KV Batch Get Keys
0
KV Batch Get Calls
0
KV Eager Mutation Submissions
0
Catalog Relation Inventory Loads
0
Catalog Type Lookups
0
Catalog Type Inventory Loads
0
Planner Build Logical Calls
1
Planner Prepare Contexts Calls
1
Planner Optimize Logical Calls
1

Photos per category

SELECT category, count(*) AS photos FROM photos GROUP BY category ORDER BY category
Photos per category, result
categoryphotos
EXPLAIN
Sort  (cost=685.39..685.39 rows=100 width=80)
  Sort Key: category
  ->  HashAggregate  (cost=11.00..21.00 rows=100 width=80)
        Group Key: category
        ->  Seq Scan on photos  (cost=0.00..11.00 rows=1000 width=320)
EXPLAIN ANALYZE
Sort  (cost=685.39..685.39 rows=100 width=80)
  Sort Key: category
  ->  HashAggregate  (cost=11.00..21.00 rows=100 width=80)
        Group Key: category
        ->  Seq Scan on photos  (cost=0.00..11.00 rows=1000 width=320)
Actual Rows: 0
Execution Time: 0.929 ms
Catalog Descriptor Loads: 0
Catalog Descriptor Hits: 2
Catalog Invocation Point Loads: 0
Catalog Invocation Point Hits: 0
Catalog Invocation Batch Loads: 0
Catalog Invocation Batch Keys: 0
Catalog Invocation Batch Hits: 0
Catalog Routine Inventory Loads: 0
KV Table Scan Pairs: 0
KV Table Scan Requests: 1
KV Index Scan Pairs: 0
KV Batch Get Keys: 0
KV Batch Get Calls: 0
KV Eager Mutation Submissions: 0
Catalog Relation Inventory Loads: 0
Catalog Type Lookups: 0
Catalog Type Inventory Loads: 0
Planner Build Logical Calls: 1
Planner Prepare Contexts Calls: 1
Planner Optimize Logical Calls: 1
Catalog Descriptor Loads
0
Catalog Descriptor Hits
2
Catalog Invocation Point Loads
0
Catalog Invocation Point Hits
0
Catalog Invocation Batch Loads
0
Catalog Invocation Batch Keys
0
Catalog Invocation Batch Hits
0
Catalog Routine Inventory Loads
0
KV Table Scan Pairs
0
KV Table Scan Requests
1
KV Index Scan Pairs
0
KV Batch Get Keys
0
KV Batch Get Calls
0
KV Eager Mutation Submissions
0
Catalog Relation Inventory Loads
0
Catalog Type Lookups
0
Catalog Type Inventory Loads
0
Planner Build Logical Calls
1
Planner Prepare Contexts Calls
1
Planner Optimize Logical Calls
1