Unable to access graph after re-login - agens-graph

I created graph on AgensGraph.
$ agens
agens (AgensGraph 2.1.0, based on PostgreSQL 10.4)
Type "help" for help.
agens=# create graph g;
CREATE GRAPH
agens=# create (:v{id:1});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
agens=# \q
$ agens
agens (AgensGraph 2.1.0, based on PostgreSQL 10.4)
Type "help" for help.
agens=# match (n) return n;
ERROR: graph_path is NULL
HINT: Use SET graph_path
agens=# \q
But, unable to access graph after re-login.
How to access graph after re-login

Use "ALTER USER ... SET GRAPH_PATH TO ..." statement for set default graph on login.
$ agens
agens (AgensGraph 2.1.0, based on PostgreSQL 10.4)
Type "help" for help.
agens=# create graph g;
CREATE GRAPH
agens=# alter user agens set graph_path to g;
ALTER ROLE
agens=# create (:v{id:1});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
agens=# \quit
After changing "GRAPH_PATH", You can access to your graph.
$ agens
agens (AgensGraph 2.1.0, based on PostgreSQL 10.4)
Type "help" for help.
agens=# match (n) return n;
n
-----------------
v[3.1]{"id": 1}
(1 row)

Related

How to find all property names of label on AgensGraph?

I want to find all property names of specific label on AgensGraph.
Which command am I use?
There is no command to find property names.
But, you can use function "jsonb_object_keys" for it.
agens=# create (:v1{key:1,value:2});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
agens=# create (:v1{id:1,text:'value'});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
agens=# match (n:v1) return distinct jsonb_object_keys( properties(n) );
jsonb_object_keys
-------------------
"text"
"id"
"value"
"key"
(4 rows)

How to find lock-wait queries on AgentGraph?

I'm suffering from slow transaction of AgensGraph.
CPU Usage is extremely low.
I'm guessing that lock-wait situation.
How to find lock-wait queries?
You can try lock-wait log of AgensGraph.
First, change parameters on "postgresql.conf"
log_lock_waits = on
deadlock_timeout = 1s
Second, restart AgensGraph.
$ ag_ctl stop
waiting for server to shut down.... done
server stopped
$ ag_ctl start
server starting
Finally, run queries and check log file.
[Session1 : block tran]
agens=# begin;
BEGIN
agens=# create (:n{id:1});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
agens=# rollback;
ROLLBACK
agens=#
[Session2 : lock-wait transaction ]
agens=# create (:n{id:1});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
Check log from log file.
LOG: process 3908 still waiting for ShareLock on transaction 1586 after 1001.058 ms
DETAIL: Process holding the lock: 3906. Wait queue: 3908.
CONTEXT: while inserting index tuple (0,7) in relation "n_id_idx"
STATEMENT: create (:n{id:1});
LOG: process 3908 acquired ShareLock on transaction 1586 after 4639.630 ms
CONTEXT: while inserting index tuple (0,7) in relation "n_id_idx"
STATEMENT: create (:n{id:1});

Unable to access to created graph on AgensGraph

Unalbe to access on graph after re-login.
$ agens
agens (AgensGraph 1.3, based on PostgreSQL 10.3)
Type "help" for help.
agens=# create graph graph;
CREATE GRAPH
agens=# match (n) return n;
n
---
(0 rows)
agens=# \q
$ agens
agens (AgensGraph 1.3, based on PostgreSQL 10.3)
Type "help" for help.
agens=# match (n) return n;
ERROR: graph_path is NULL
HINT: Use SET graph_path
agens=# \q
How can I access to created graph?
How can I call "set graph_path" on login automatically?
Use "set graph_path" command for search on your graph.
agens (AgensGraph 1.3, based on PostgreSQL 10.3)
Type "help" for help.
agens=# set graph_path to graph;
SET
agens=# match (n) return n;
n
---
(0 rows)
agens=# \q
$ agens
agens (AgensGraph 1.3, based on PostgreSQL 10.3)
Type "help" for help.
agens=# match (n) return n;
ERROR: graph_path is NULL
HINT: Use SET graph_path
agens=# \q
But, You must set graph_path everytime on login.
For avoid inconvenience, You can set graph_path on your account.
$ agens
agens (AgensGraph 1.3, based on PostgreSQL 10.3)
Type "help" for help.
agens=# alter user agens set graph_path to graph;
ALTER ROLE
agens=# \q
$ agens
agens (AgensGraph 1.3, based on PostgreSQL 10.3)
Type "help" for help.
agens=# match (n) return n;
n
---
(0 rows)
agens=# \q
Use "alter user" for set graph_path of user.

How to load file on AgensGraph?

I tried to load comma separated file on agensgraph.
But agensgraph does not have load utility on package.
How can I load file on agensgraph?
You can use "Foreign Data Wrapper", Instead of utility.
First, create file few extension.
agens=# CREATE EXTENSION file_fdw;
CREATE EXTENSION
Second, create server object.
agens =# CREATE SERVER graph_import FOREIGN DATA WRAPPER file_fdw;
CREATE SERVER
Next, create foreign table with file.
agens =# CREATE FOREIGN TABLE fdwSample
agens-# (
agens(# id INT8,
agens(# name VARCHAR(256)
agens(# )
agens-# SERVER graph_import
agens-# OPTIONS
agens-# (
agens(# FORMAT 'csv',
agens(# HEADER 'false',
agens(# DELIMITER ',',
agens(# NULL '',
agens(# FILENAME 'sample.dat'
agens(# );
CREATE FOREIGN TABLE
Last, load file use "LOAD" clause.
agens=# LOAD FROM fdwSample AS sample
agens-# CREATE (:node {id:sample.id,name:sample.name});
GRAPH WRITE (INSERT VERTEX 2, INSERT EDGE 0)
After all, you can find loaded data.
agens =# MATCH (n:node) RETURN n;
n
-------------------------------------
node[3.1]{"id": 1, "name": "steve"}
node[3.2]{"id": 2, "name": "bill"}
(2 rows)
Good luck.

how to check default column value in sqlite3 is set to infinite in "c" / native sqlite3

I have attempted to establish a graph using sqlite3 as follows, and just wanted to know how I may check that the "infinite" value in the graph is treated as infinite by sqlite3.
sqlite> create table graph(nodeA INT, nodeB INT, length INT DEFAULT inf);
sqlite> insert into graph values(1,2,0);
sqlite> insert into graph values(1,3,null);
sqlite> insert into graph values (2,3,"inf");
sqlite> select * from graph;
1|2|0
1|3|
2|3|inf
Any good suggestions?

Resources