Finding current running match / merge etc

Morning all.

  1. Trying to find all the match commands in effect. googling gave me:
  • CALL dbms.listQueries();

  • CALL dbms.queryJmx("org.neo4j:instance=kernel#0, name=Queries");

  • :queries;

    All came back with one error or the other.

  1. If I issue a merge, I’m guessing that is just executed at that time, it’s not something like a match that will sit in the back ground and continuously run?

G

Correct, the cypher is executed once when submitted. You would have to write your own scheduled task if you want something like that.

hmmm.
ok hold on, might have my above question wrong.

I have a set of bank nodes, account nodes, accountHolder nodes.
created and they are joined using match statements creating the joining edges.

how can i see which match statements are configured.

G

@georgelza

What versions of Neo4j. Your initial post with the methods to determine is ‘true’ but only so much as what version of Neo4j you are running. For Neo4j 2025.x see Manage queries - Operations Manual which states

List all running queries
The procedure for listing queries, dbms.listQueries(), is replaced by the
command for listing transactions, SHOW TRANSACTIONS. This command 
returns information about the currently executing query in the 
transaction. For more information on the command, see the Cypher
 manual → SHOW TRANSACTIONS command.

As to MERGE since MERGE is a update or create, for an update to occur it needs to lock the object 1st. But if some other cypher currently has the object locked, then the MERGE will wait until the lock is acquired.

Not sure what you mean about “match statements configured?” You used match/merged to create your graph. The graph is the artifact. There isn’t a match configuration that results. What is your objective?

ok, lets see, might be gap in my education.

If create set of nodes with Merge or creates, say Banks, Accounts and AccountHolders.

I then create edges between them using a match syntax

I now add more nodes to Banks, Accounts and AccountHolders.

What am I expect to see, will the edges between the new nodes be added using the previous Match command or do I need to rerun that match command.

Lets get this clarified first as it might answer the 2nd part of the question.

G

MATCH is the equivalent of a SELECT

CREATE and MERGE are the equivalent of an INSERT

Nodes and edges both follow the same principles for creation.

So pretty much after any/all CREATE or MERGE’s the desired MATCH statements needs to be rerun to create the new edges thats available based on the new nodes.

thank you.

G

No … a MATCH is just a query (it is telling you what is in the graph) … like a SELECT

You create nodes and edges with cypher queries using create, match, and merge. You then use match to find the entities you need for your analysis. The key is you use patterns to match the entities and relationships you want when querying to data.

@glilienfield

I think saying MATCH is used to create nodes is confusing - it helps by collecting information to be used by a CREATE or MERGE

MATCH (u:User {name: "Alice"})                    // collects information
MERGE (u)-[:FRIENDS_WITH]->(f:User {name: "Bob"}) // to be used by a MERGE

Running this ns Cypher at console

MATCH (bank:Bank)
MATCH (acc:Account)
WHERE bank.fspiId = acc.fspiId
MERGE (bank)-[:OWNS]->(acc);

then going onto web console and asking for it to show me edges shows me the edges/links created due to the above. implying it creates a process that says when i ask for

MATCH p=()-[]->() RETURN p ;

It then returns the MATCHES as defined above, which is persisted some where as a match that i want defined.

So part of my query is, if i now add new records to say the above Account node. if I then execute

MATCH p=()-[]->() RETURN p ;

would they show… or do i need to rerun

MATCH (bank:Bank)
MATCH (acc:Account)
WHERE bank.fspiId = acc.fspiId
MERGE (bank)-[:OWNS]->(acc);

to discover / mark / create the edges, to be shown when i execute

MATCH p=()-[]->() RETURN p ;

This:

MATCH p=()-[]->() RETURN p ;

It's just telling you what you have on your graph, it will return ALL nodes that are in that set.

Further, comments next to your query:

This is your before / after executing that query:

ye i know this..
look at my question.

if i load nodes 1-5 for banks 1 -5

then loads clients 1-20

lets say 1-15 is clients of the 5 banks.

I now run a match command as per above

followed by MATCH p=()-[]->() RETURN p ;

that will now show me the 5 banks and the 15 people.

I i now add a 6th bank…

and rerun MATCH p=()-[]->() RETURN p ;

will it show the remaining 5 people matched to the 6th bank or do i first need to run the

MATCH (bank:Bank)                // this first three lines
MATCH (acc:Account)              // return ANY 2 nodes bank and acc
WHERE bank.fspiId = acc.fspiId   // where the fspiId is equal
MERGE (bank)-[:OWNS]->(acc);     // then merges an edge [:OWNS] on all of those pairs

and can then run MATCH p=()-[]->() RETURN p ; to see the links having been ?

If you add a Node and don’t add relationships, then the specific match from your query will not return anything (that is returning nodes that are connected to other nodes).

ok…

so execution time. how does it know only to scan new nodes and do a update for them and not scan all nodes. otherwise this gets more expansive the bigger the deployment.

G

I think perhaps the confusion arises from the fact that in ERD/SQL, there is a concept of a foreign key, meaning that the “edge” from one table to another is constrained by that key, and in the diagram, it appears as an edge.

Here, you have to be more explicit; there are “constraints” for nodes, but those are introspections (“property existence/uniqueness/type/identifier”).

Your nodes will have indices - the labels like:Account or :Bank are a type of index (same with the edges [:own], etc) … you can then specify your own (like fspiId will have a uniqueness constraint for a bank, and an index to scan the space for that property faster).