-1

I'm currently working on an Apache-age graph and need to retrieve the OID values for the label relations in the graph. I'm using Postgres to manage my database and have tried querying the ag_labels schema, but it doesn't seem to contain the OID values for the label relations.

Here's the code I've tried so far:

SELECT oid, relname FROM pg_class WHERE relkind = 'r' AND relname LIKE 'ag_labels_%';

This query returns the relname values for all label relations in my graph, but not the OID values.

I've also tried querying the pg_catalog.pg_class table directly, but this doesn't seem to return the OID values for the label relations either.

I'm wondering if there's another table or schema I should be looking at to retrieve the OID values for label relations in Apache-age. Any suggestions or insights would be greatly appreciated.

Thanks in advance!

5 Answers5

0

I dont think there is a single query you can run to see all the oids of the existing labels. The labels are stored in the ag.label table but that doesn't hold information about the OID. What you could try is first querying for all the labels with

SELECT * FROM ag_label;

and then run

SELECT oid, relname FROM pg_class WHERE relkind = 'r';

and in the returned rows find the names and oids of the labels you are looking for.

0

If you run the query:

SELECT oid, relname FROM pg_class WHERE relkind = 'r';

It will return oids as well like this:

postgres=# SELECT oid, relname FROM pg_class WHERE relkind = 'r';
  oid  |         relname         
-------+-------------------------
  2619 | pg_statistic
  1247 | pg_type
 27575 | _ag_label_vertex
 27585 | _ag_label_edge
 35178 | ag_graph
 35190 | ag_label
  3118 | pg_foreign_table
 35771 | _ag_label_vertex
  1260 | pg_authid
 35791 | Person
 35781 | _ag_label_edge
 35800 | RELTYPE
  3429 | pg_statistic_ext_data
  1418 | pg_user_mapping
  6100 | pg_subscription

The other condition "relname LIKE 'ag_labels_%'" might be the reason you are not getting the desired results.

han
  • 74
  • 7
0

Perhaps you're looking for the command

SELECT oid, relation FROM ag_label;

It returns the OIDs of all the labels in your database, something like this:

  oid   |           relation
--------+------------------------------
 803774 | test_graph._ag_label_vertex
 803787 | test_graph._ag_label_edge
 803799 | test_graph."Person"
 803811 | test_graph."MARRIED_TO"
 803823 | test_graph."PARENT_OF"
 803835 | test_graph."BROTHER_OF"
(6 rows)
Marco Souza
  • 296
  • 7
0

Try these steps:

  1. open the configuration file oof apache-age
  2. Secondly find the track-oid and turn it on. And to add it you can do this:

autovacuum = on

track_oid = on
  1. Now save that fine and restart the server to apply changes.

After doing all the above steps , you can now use this query for the retrieval.

SELECT oid, relname FROM pg_catalog.pg_class WHERE relkind = 'r' AND relname LIKE 'ag_labels_%';
0

You can run this query to retrieve id's of all the edges and vertices of a specific graph and label.

SELECT * FROM test."Node";
       id        |      properties                                                                                                                                  
             
-----------------+-----------------------------------------------------------

 844424930131971 | {name: 'A'}
 844424930131972 | {name: 'B'}
 844424930131973 | {name: 'C'}
(3 rows)

"test" is graph name and "Node" is label name. Replace it with you own data.