Skip to content

Commit c430770

Browse files
ibarwickdjw-m
authored andcommitted
PGD: document new function "bdr.galloc_chunk_info()" (WIP)
This function removes the need to query galloc sequences allocated on the local node by referencing hidden rows by their CTID, which is really not something we want end users to be doing. DOCS-1258.
1 parent 47b2f23 commit c430770

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

product_docs/docs/pgd/5.7/reference/sequences.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,25 @@ bdr.timestamp_to_timeshard(ts timestamptz)
220220

221221
- `ts` — Timestamp to use for the `timeshard` sequence generation.
222222

223+
### `bdr.galloc_chunk_info`
224+
225+
This function retrieves the ranges allocated to a galloc sequence on the local
226+
node.
227+
228+
An empty result set will be returned if the sequence has not yet been accessed
229+
on the local node.
230+
231+
An ERROR will be raised if the provided sequence name is not a galloc sequence.
232+
233+
#### Synopsis
234+
235+
```sql
236+
bdr.galloc_chunk_info(seqname regclass)
237+
```
238+
#### Parameters
239+
240+
- `seqname` - the name of the galloc sequence to query
241+
223242
#### Notes
224243

225244
This function executes only on the local node.

product_docs/docs/pgd/5.7/sequences.mdx

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -332,48 +332,30 @@ SELECT * FROM bdr.sequence_alloc
332332
(1 row)
333333
```
334334

335-
To see the ranges currently assigned to a given sequence on each node, use
336-
these queries:
335+
To see the ranges currently assigned to a given sequence on each node, execute the function
336+
[`bdr.galloc_chunk_info`](reference/sequences/#bdrgalloc_chunk_info).
337337

338-
* Node `Node1` is using range from `333` to `2000333`.
338+
* Node `Node1` is using range from `334` to `2000333`.
339339

340340
```sql
341-
SELECT last_value AS range_start, log_cnt AS range_end
342-
FROM categories_category_seq WHERE ctid = '(0,2)'; -- first range
343-
range_start | range_end
341+
SELECT * FROM bdr.galloc_chunk_info('categories_category_seq');
342+
chunk_start | chunk_end
344343
-------------+-----------
345344
334 | 1000333
346-
(1 row)
347-
348-
SELECT last_value AS range_start, log_cnt AS range_end
349-
FROM categories_category_seq WHERE ctid = '(0,3)'; -- second range
350-
range_start | range_end
351-
-------------+-----------
352345
1000334 | 2000333
353-
(1 row)
346+
(2 rows)
354347
```
355348

356349
* Node `Node2` is using range from `2000334` to `4000333`.
357350

358351
```sql
359-
SELECT last_value AS range_start, log_cnt AS range_end
360-
FROM categories_category_seq WHERE ctid = '(0,2)'; -- first range
361-
range_start | range_end
352+
SELECT * FROM bdr.galloc_chunk_info('categories_category_seq');
353+
chunk_start | chunk_end
362354
-------------+-----------
363355
2000334 | 3000333
364-
(1 row)
365-
366-
SELECT last_value AS range_start, log_cnt AS range_end
367-
FROM categories_category_seq WHERE ctid = '(0,3)'; -- second range
368-
range_start | range_end
369-
-------------+-----------
370356
3000334 | 4000333
371357
```
372358

373-
!!! NOTE
374-
You can't combine it to a single query (like `WHERE ctid IN ('(0,2)', '(0,3)')`),
375-
as that still shows only the first range.
376-
377359
When a node finishes a chunk, it asks a consensus for a new one and gets the
378360
first available. In the example, it's from 4000334 to 5000333. This is
379361
the new reserved chunk and starts to consume the old reserved chunk.

0 commit comments

Comments
 (0)