PostgreSQL
Tables
cafes13 rows
| Column | Type | Null | Default |
|---|---|---|---|
| id | integer | no | |
| display_name | text | no | |
| official_name | text | no | |
| name_ja | text | yes | |
| prefecture | text | no | |
| city | text | no | |
| area | text | no | |
| nearest_station | text | yes | |
| kind | text | no | |
| status | text | no | |
| morning_service | boolean | yes | |
| url | text | yes | |
| source_url | text | no | |
| confidence | text | no |
- PRIMARY KEYcafes_pkey
(id) - CHECKcafes_status_check
(status IN ('open', 'closed', 'uncertain'))
curry_shops3 rows
| Column | Type | Null | Default |
|---|---|---|---|
| id | integer | no | |
| display_name | text | no | |
| official_name | text | no | |
| name_ja | text | yes | |
| prefecture | text | no | |
| city | text | no | |
| area | text | no | |
| nearest_station | text | yes | |
| kind | text | no | |
| status | text | no | |
| url | text | yes | |
| source_url | text | no | |
| confidence | text | no |
- PRIMARY KEYcurry_shops_pkey
(id) - CHECKcurry_shops_status_check
(status IN ('open', 'closed', 'uncertain'))
izakaya1 row
| Column | Type | Null | Default |
|---|---|---|---|
| id | integer | no | |
| display_name | text | no | |
| official_name | text | no | |
| name_ja | text | yes | |
| prefecture | text | no | |
| city | text | no | |
| area | text | no | |
| nearest_station | text | yes | |
| kind | text | no | |
| status | text | no | |
| url | text | yes | |
| source_url | text | no | |
| confidence | text | no |
- PRIMARY KEYizakaya_pkey
(id) - CHECKizakaya_status_check
(status IN ('open', 'closed', 'uncertain'))
photos0 rows
| Column | Type | Null | Default |
|---|---|---|---|
| id | text | no | |
| category | text | no | |
| src | text | no | |
| width | integer | no | |
| height | integer | no | |
| taken_at | date | yes | |
| caption | text | no | ''::text |
| alt | text | no |
- PRIMARY KEYphotos_pkey
(id) - CHECKphotos_category_check
(category IN ('coffee', 'curry', 'izakaya')) - CHECKphotos_height_check
(height > 0) - CHECKphotos_width_check
(width > 0)
journal0 rows
| Column | Type | Null | Default |
|---|---|---|---|
| slug | text | no | |
| title | text | no | |
| lang | text | no | |
| like_slug | text | yes | |
| published_at | timestamp with time zone | no | |
| body | text | no | |
| content_hash | text | no |
- 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| city | cafes |
|---|---|
| Nagoya | 8 |
| Gifu | 1 |
| Koto | 1 |
| Nagakute | 1 |
| Shibuya | 1 |
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)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| display_name | area |
|---|---|
| SILVIA | Karayama-cho |
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)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| display_name | area | kind |
|---|---|---|
| Q.O.L.COFFEE | Marunouchi | roaster + specialty coffee shop |
Index Scan using cafes_pkey on cafes (cost=0.00..1.50 rows=1 width=560)
Index Cond: (id = 1)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| list | display_name | status |
|---|---|---|
| curry | Trippin' Curry | closed |
| curry | chikaku | open |
| curry | toi | open |
| izakaya | Teppanyaki Ichitora | open |
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)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| category | photos |
|---|
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)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
