This is a document for PGroonga 2.X and 3.X. See PGroonga 1.x document when you're using old PGroonga.
pgroonga_list_lagged_indexes
functionSince 3.2.1.
pgroonga_list_lagged_indexes
function display a index of PGroonga with unapplied PGroonga WAL (not PostgreSQL WAL).
Specifically, it displays the following cases:
If current_*
and last_*
in pgroonga_wal_status
function are different
If flushed_lsn
and latest_end_lsn*
in pg_stat_wal_receiver
are different
Here is the syntax of this function:
SETOF text pgroonga_list_lagged_indexes()
It gets the index of PGroonga with unapplied PGroonga WAL (not PostgreSQL WAL).
It returns the following records:
pgroonga_list_lagged_indexes
------------------------------
pgrn_memos_index
pgrn_tags_index
SELECT pgroonga_list_lagged_indexes();
It is assumed that streaming replication and pgroonga.enable_wal = yes
have already been set up.
CREATE TABLE memos (
content text
);
CREATE TABLE tags (
name text
);
CREATE INDEX pgrn_memos_index ON memos USING PGroonga (content);
CREATE INDEX pgrn_tags_index ON tags USING PGroonga (name);
PGroonga WAL not applied:
SELECT name,
current_block,
current_offset,
current_size,
last_block,
last_offset,
last_size
FROM pgroonga_wal_status();
name | current_block | current_offset | current_size | last_block | last_offset | last_size
------------------+---------------+----------------+--------------+------------+-------------+-----------
pgrn_memos_index | 0 | 0 | 0 | 1 | 566 | 8758
pgrn_tags_index | 0 | 0 | 0 | 1 | 560 | 8752
(2 rows)
SELECT pgroonga_list_lagged_indexes();
pgroonga_list_lagged_indexes
------------------------------
pgrn_memos_index
pgrn_tags_index
(2 rows)
PGroonga WAL already applied in some PGroonga indexes:
SELECT * FROM tags WHERE name &@ 'dummy';
name
------
(0 rows)
SELECT name,
current_block,
current_offset,
current_size,
last_block,
last_offset,
last_size
FROM pgroonga_wal_status();
name | current_block | current_offset | current_size | last_block | last_offset | last_size
------------------+---------------+----------------+--------------+------------+-------------+-----------
pgrn_memos_index | 0 | 0 | 0 | 1 | 566 | 8758
pgrn_tags_index | 1 | 560 | 8752 | 1 | 560 | 8752
(2 rows)
SELECT pgroonga_list_lagged_indexes();
pgroonga_list_lagged_indexes
------------------------------
pgrn_memos_index
(1 row)
PGroonga WAL is applied to all PGroonga indexes:
SELECT pgroonga_wal_apply();
pgroonga_wal_apply
--------------------
7
(1 row)
SELECT name,
current_block,
current_offset,
current_size,
last_block,
last_offset,
last_size
FROM pgroonga_wal_status();
name | current_block | current_offset | current_size | last_block | last_offset | last_size
------------------+---------------+----------------+--------------+------------+-------------+-----------
pgrn_memos_index | 1 | 566 | 8758 | 1 | 566 | 8758
pgrn_tags_index | 1 | 560 | 8752 | 1 | 560 | 8752
(2 rows)
SELECT pgroonga_list_lagged_indexes();
pgroonga_list_lagged_indexes
------------------------------
(0 rows)