Graph views#
Two views in pg_catalog present the graph catalogs in a readable form, resolving oids and
label ids to names. Both are ordinary views, so you can join and filter them.
ag_property_indexes#
One row per property index, with the statement that would recreate it.
Column |
Type |
Description |
|---|---|---|
|
|
The graph the index belongs to. |
|
|
The label the index is on. |
|
|
The index’s name. |
|
|
The tablespace, or null for the default. |
|
|
Whether the index is unique. |
|
|
A |
|
|
The role that owns the index. |
|
|
The index’s size, already formatted. |
|
|
The comment on the index, if any. |
The example dataset has no property indexes, so create two to have something to look at:
CREATE PROPERTY INDEX ON movie (title);
CREATE PROPERTY INDEX ON person (name);
SELECT labelname, indexname, indexdef, size
FROM pg_catalog.ag_property_indexes
WHERE graphname = 'moviekb' ORDER BY labelname, indexname;
labelname | indexname | indexdef | size
-----------+-----------------+--------------------------------------------------------------------+-------
movie | movie_title_idx | CREATE PROPERTY INDEX movie_title_idx ON movie USING btree (title) | 16 kB
person | person_name_idx | CREATE PROPERTY INDEX person_name_idx ON person USING btree (name) | 16 kB
Drop them again with DROP PROPERTY INDEX movie_title_idx; when you are done.
The indexdef column is the useful one. It gives back the property-level statement rather
than the expression index the server built, and that is the form you want when scripting a
schema. \dGi in the agens client prints the same information.
The view lists indexes on promoted columns as well as indexes over the property bag. So it is the single place to look for “what is indexed on this label”.
ag_graphmeta_view#
One row per edge shape that occurs in a graph, with names instead of label ids.
Column |
Type |
Description |
|---|---|---|
|
|
The graph. |
|
|
The label of the edge’s start vertex. |
|
|
The edge label. |
|
|
The label of the edge’s end vertex. |
|
|
How many edges of that shape exist. |
SELECT * FROM pg_catalog.ag_graphmeta_view WHERE graphname = 'moviekb';
graphname | start | edge | end | edgecount
-----------+--------+------------+-------+-----------
moviekb | movie | related_to | movie | 11
moviekb | person | directed | movie | 21
moviekb | person | acted_in | movie | 25
This is the clearest picture of a graph’s actual shape that AgensGraph can give you. Read it before tuning a query: it tells you which traversals exist and how big each one is. The planner uses the same rows.
The view is empty unless the metadata has been gathered. See Graph
metadata for auto_gather_graphmeta and regather_graphmeta(), and
check ag_graph.graphmeta_valid if the numbers look wrong.