How to drop property constraint on AgensGraph? - agens-graph

I want to drop property index on AgensGraph.
agens=# create vlabel v;
CREATE VLABEL
agens=# create elabel e;
CREATE ELABEL
agens=# create property index on v ( id );
CREATE PROPERTY INDEX
agens=# create property index on e ( id );
CREATE PROPERTY INDEX
agens=# drop property index on v ( id );
ERROR: syntax error at or near "on"
LINE 1: drop property index on v ( id );
^
agens=# drop property index on e ( id );
ERROR: syntax error at or near "on"
LINE 1: drop property index on e ( id );
^
But, there is some problem on grammar.
How to drop property constraint on AgensGraph?

Name of property index is created automatically at creation time.
You can use '\dGe' and '\dGe' for find structure of labels.
agens=# \dGv v
List of labels
Graph | Name | Type | Owner
-------+------+--------+-------
graph | v | vertex | agens
(1 row)
Vertex label "graph.v"
--
Property Indexes:
"v_id_idx" btree (id)
Inherits: graph.ag_vertex
agens=# \dGe e
List of labels
Graph | Name | Type | Owner
-------+------+------+-------
graph | e | edge | agens
(1 row)
Edge label "graph.e"
--
Property Indexes:
"e_id_idx1" btree (id)
Inherits: graph.ag_edge
After search index name, drop property index next.
agens=# drop property index v_id_idx;
DROP PROPERTY INDEX
agens=# drop property index e_id_idx1;
DROP PROPERTY INDEX

Related

How to find internal vertices in variable-length-edges on AgensGraph?

I tried to find internal vertices in variable-length-edges on AgensGraph.
But, It returns error message like following.
Is there problem on CYPHER query on mime?
How can I view internal vertices of VLE?
Attaching sample script follow.
create graph vle;
create vlabel o;
create vlabel l;
create elabel e;
create property index on o ( id );
create property index on l ( id );
create property index on e ( id );
create (:o{id:1})
create (:o{id:2})
create (:o{id:3})
create (:o{id:4})
create (:o{id:5})
create (:o{id:6})
create (:o{id:7})
create (:o{id:8})
create (:o{id:9});
match (o:o) create (:v{id:o.id});
match (n:v) where n.id >= 1 and n.id <= 9
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+1)}]->(:v{id:n.id*10+1})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+2)}]->(:v{id:n.id*10+2})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+3)}]->(:v{id:n.id*10+3})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+4)}]->(:v{id:n.id*10+4})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+5)}]->(:v{id:n.id*10+5})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+6)}]->(:v{id:n.id*10+6})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+7)}]->(:v{id:n.id*10+7})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+8)}]->(:v{id:n.id*10+8})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+9)}]->(:v{id:n.id*10+9});
match (n:v) where n.id >= 11 and n.id <= 99
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+1)}]->(:v{id:n.id*10+1})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+2)}]->(:v{id:n.id*10+2})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+3)}]->(:v{id:n.id*10+3})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+4)}]->(:v{id:n.id*10+4})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+5)}]->(:v{id:n.id*10+5})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+6)}]->(:v{id:n.id*10+6})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+7)}]->(:v{id:n.id*10+7})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+8)}]->(:v{id:n.id*10+8})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+9)}]->(:v{id:n.id*10+9});
match (n:v) where n.id >= 111 and n.id <= 999
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+1)}]->(:v{id:n.id*10+1})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+2)}]->(:v{id:n.id*10+2})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+3)}]->(:v{id:n.id*10+3})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+4)}]->(:v{id:n.id*10+4})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+5)}]->(:v{id:n.id*10+5})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+6)}]->(:v{id:n.id*10+6})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+7)}]->(:v{id:n.id*10+7})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+8)}]->(:v{id:n.id*10+8})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+9)}]->(:v{id:n.id*10+9});
match (n:v) where n.id >= 1111 and n.id <= 9999
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+1)}]->(:v{id:n.id*10+1})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+2)}]->(:v{id:n.id*10+2})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+3)}]->(:v{id:n.id*10+3})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+4)}]->(:v{id:n.id*10+4})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+5)}]->(:v{id:n.id*10+5})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+6)}]->(:v{id:n.id*10+6})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+7)}]->(:v{id:n.id*10+7})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+8)}]->(:v{id:n.id*10+8})
create (n)-[:e{id:'v:'+n.id+'->v:'+(n.id*10+9)}]->(:v{id:n.id*10+9});
match p = ( (v1:v{id:1})-[:e*]->(v2:v{id:11111}) ) return nodes(p);
ERROR: graph path and variable length edge cannot be used at the same time
LINE 1: match p = ( (v1:v{id:1})-[:e*]->(v2:v{id:11111}) ) return no...
^
Please, help...
It is impossible to get nodes between VLE path on older version of AgensGraph.
Think upgrading version of AgensGraph.
agens (AgensGraph 2.1.0, based on PostgreSQL 10.4)
Type "help" for help.
agens =# match p = ( (v1:v{id:1})-[:e*]->(v2:v{id:11111}) ) return nodes(p);
nodes
----------------------------------------------------------------------------------------------------
[v[6.1]{"id": 1},v[6.10]{"id": 11},v[6.91]{"id": 111},v[6.820]{"id": 1111},v[6.7381]{"id": 11111}]
(1 row)

How can I increase performance of shortest-path on AgensGraph?

I tried to use shortest-path on AgensGraph.
But, It is quietly slower than other graph database.
How can I increase performance of shortest-path on AgensGraph?
I want to some tips or configuration parameters.
Attaching sample script follow.
create graph shortestpath;
create vlabel o;
create vlabel l;
create elabel e;
create property index on o ( id );
create property index on l ( id );
create property index on e ( id );
create (:o{id:1})
create (:o{id:2})
create (:o{id:3})
create (:o{id:4})
create (:o{id:5})
create (:o{id:6})
create (:o{id:7})
create (:o{id:8})
create (:o{id:9});
match (o:o) create (:l{id:o.id});
match (n:l) where n.id >= 1 and n.id <= 9
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+1)}]->(:l{id:n.id*10+1})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+2)}]->(:l{id:n.id*10+2})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+3)}]->(:l{id:n.id*10+3})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+4)}]->(:l{id:n.id*10+4})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+5)}]->(:l{id:n.id*10+5})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+6)}]->(:l{id:n.id*10+6})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+7)}]->(:l{id:n.id*10+7})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+8)}]->(:l{id:n.id*10+8})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+9)}]->(:l{id:n.id*10+9});
match (n:l) where n.id >= 11 and n.id <= 99
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+1)}]->(:l{id:n.id*10+1})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+2)}]->(:l{id:n.id*10+2})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+3)}]->(:l{id:n.id*10+3})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+4)}]->(:l{id:n.id*10+4})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+5)}]->(:l{id:n.id*10+5})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+6)}]->(:l{id:n.id*10+6})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+7)}]->(:l{id:n.id*10+7})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+8)}]->(:l{id:n.id*10+8})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+9)}]->(:l{id:n.id*10+9});
match (n:l) where n.id >= 111 and n.id <= 999
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+1)}]->(:l{id:n.id*10+1})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+2)}]->(:l{id:n.id*10+2})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+3)}]->(:l{id:n.id*10+3})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+4)}]->(:l{id:n.id*10+4})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+5)}]->(:l{id:n.id*10+5})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+6)}]->(:l{id:n.id*10+6})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+7)}]->(:l{id:n.id*10+7})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+8)}]->(:l{id:n.id*10+8})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+9)}]->(:l{id:n.id*10+9});
match (n:l) where n.id >= 1111 and n.id <= 9999
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+1)}]->(:l{id:n.id*10+1})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+2)}]->(:l{id:n.id*10+2})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+3)}]->(:l{id:n.id*10+3})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+4)}]->(:l{id:n.id*10+4})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+5)}]->(:l{id:n.id*10+5})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+6)}]->(:l{id:n.id*10+6})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+7)}]->(:l{id:n.id*10+7})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+8)}]->(:l{id:n.id*10+8})
create (n)-[:e{id:'l:'+n.id+'->l:'+(n.id*10+9)}]->(:l{id:n.id*10+9});
\timing
match p = allshortestpaths( (l1:l)-[:e*]->(l2:l) ) where l1.id = 1 and l2.id = 11111 return l1.id as l1id, l2.id as l2id, count(p) order by l1id, l2id;
l1id | l2id | count
------+-------+-------
1 | 11111 | 1
(1 row)
Time: 133.547 ms
Is it possible that improve to under 10ms.
There is an improvement on Shortest-Path on "AgensGraph Version 2.1".
Algorithm is changed to "Bidirectional BFS" from "BFS".
agens (AgensGraph 2.1.0, based on PostgreSQL 10.4)
Type "help" for help.
match p = allshortestpaths( (l1:l)-[:e*]->(l2:l) ) where l1.id = 1 and l2.id = 11111 return l1.id as l1id, l2.id as l2id, count(p) order by l1id, l2id;
l1id | l2id | count
------+-------+-------
1 | 11111 | 1
(1 row)
Time: 1.776 ms
If you use "Version 1.3" or "Version 2.0", It is better choice upgrade to "Version 2.1"

How to create node on AgensGraph?

After connected to AgensGraph.
I try to create node on AgensGraph.
But, there is a error on action.
kurt=# create (:v{id:1});
ERROR: graph_path is NULL
HINT: Use SET graph_path
How to set graph_path?
You must create graph, before create vertex(node).
assam=# create graph new_graph;
CREATE GRAPH
After creating graph, set graph_path.
assam=# set graph_path = new_graph;
SET
Finally, You can create a vertex(node).
assam=# create (:v{id:1});
GRAPH WRITE (INSERT VERTEX 1, INSERT EDGE 0)
assam=# match (n:v) return n;
n
-----------------
v[3.1]{"id": 1}
(1 row)

UNIQUE INDEX not working

I have a unique index with where the condition. but it is not working. maybe I am missing something.
CREATE UNIQUE NONCLUSTERED INDEX [IDX_NBR_TIN_INFO_PASSPORT]
ON [dbo].[NBR_TIN_INFO] ([PASSPORT_NUMBER] ASC)
WHERE (([PASSPORT_NUMBER] IS NOT NULL) AND ([IS_TOKEN_APPROVED] <> 0))
GO
Data inserted in the table is shown here:
PASSPORT_NUMBER | IS_TOKEN_APPROVED
----------------+-------------------
XXX-487545 | NULL
XXX-487545 | 0
XXX-487545 | NULL
But row 1 or 3 should be blocked by index.
This happens because NULL is unknown in every comparison, i.e. neither 0 = NULL nor 0 <> NULL. Therefore, you don't get these rows indexed. Try this:
WHERE (([PASSPORT_NUMBER] IS NOT NULL)
AND ([IS_TOKEN_APPROVED]<>0 OR [IS_TOKEN_APPROVED] IS NULL))
You need to resolve this by adding both columns to your index and removing the filter
CREATE UNIQUE NONCLUSTERED INDEX [IDX_NBR_TIN_INFO_PASSPORT]
ON [dbo].[NBR_TIN_INFO] ([PASSPORT_NUMBER] ASC),
[dbo].[NBR_TIN_INFO] ([IS_TOKEN_APPROVED])
GO

SQL Server Filtered Index WHERE Column = Column

I was hoping to try use a filtered index on a table in SQL Server 2012 to see if it would improve query execution though when trying to create it I am getting the following error:
Msg 10735, Level 15, State 1, Line 3
Incorrect WHERE clause for filtered index 'IX_SRReferralIn_Filtered' on table 'dbo.SRReferralIn'.
Below is the statement I am using. RowIdentifier and IDOrganisationVisibleTo are the columns in the CLUSTERED PRIMARY KEY
CREATE NONCLUSTERED INDEX IX_SRReferralIn_Filtered
ON dbo.SRReferralIn(RowIdentifier, IDOrganisationVisibleTo)
WHERE IDOrganisationVisibleTo = IDOrganisation;
Is the expression in the WHERE clause not supported?
No this is not supported.
The grammar only allows comparisons with constants
<filter_predicate> ::=
<conjunct> [ AND <conjunct> ]
<conjunct> ::=
<disjunct> | <comparison>
<disjunct> ::=column_name IN (constant ,...n)
<comparison> ::=column_name <comparison_op> constant<comparison_op> ::=
{ IS | IS NOT | = | <> | != | > | >= | !> | < | <= | !< }
You could create an indexed view with this condition though.

Resources