Skip to content

Commit 2326e59

Browse files
committed
Add example with 'tableoid' (closes #7)
1 parent f0b9bac commit 2326e59

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Merge two adjacent RANGE partitions. Data from `partition2` is copied to `partit
120120
```
121121
append_range_partition(p_relation TEXT)
122122
```
123-
Appends new RANGE partition and returns
123+
Appends new RANGE partition and returns
124124
```
125125
prepend_range_partition(p_relation TEXT)
126126
```
@@ -160,6 +160,13 @@ disable_partitioning(relation TEXT)
160160
Disables `pg_pathman` partitioning mechanism for the specified parent table and removes an insert trigger. Partitions itself remain unchanged.
161161

162162
## Examples
163+
164+
### Common tips
165+
You can easily add **_partition_** column containing the names of the underlying partitions using the system attribute called **_tableoid_**:
166+
```
167+
SELECT tableoid::regclass, * AS partition FROM partitioned_table;
168+
```
169+
163170
### HASH
164171
Consider an example of HASH partitioning. First create a table with some integer column:
165172
```
@@ -180,13 +187,13 @@ This will create new partitions and move the data from parent to partitions.
180187
Here is an example of the query with filtering by partitioning key and its plan:
181188
```
182189
SELECT * FROM items WHERE id = 1234;
183-
id | name | code
190+
id | name | code
184191
------+----------------------------------+------
185192
1234 | 81dc9bdb52d04dc20036dbd8313ed055 | 1855
186193
(1 row)
187194
188195
EXPLAIN SELECT * FROM items WHERE id = 1234;
189-
QUERY PLAN
196+
QUERY PLAN
190197
------------------------------------------------------------------------------------
191198
Append (cost=0.28..8.29 rows=0 width=0)
192199
-> Index Scan using items_34_pkey on items_34 (cost=0.28..8.29 rows=0 width=0)
@@ -195,7 +202,7 @@ EXPLAIN SELECT * FROM items WHERE id = 1234;
195202
Note that pg_pathman excludes parent table from the query plan. To access parent table use ONLY modifier:
196203
```
197204
EXPLAIN SELECT * FROM ONLY items;
198-
QUERY PLAN
205+
QUERY PLAN
199206
------------------------------------------------------
200207
Seq Scan on items (cost=0.00..0.00 rows=1 width=45)
201208
```

0 commit comments

Comments
 (0)