The easiest way to execute Cypher queries against Memgraph is by using Memgraph’s command-line tool, mgconsole.
It is available as Docker image and as a binary for macOS, and Windows.
Install mgconsole
To install or start to query a running Memgraph database instance, use the following steps:
You can use on any OS from the Docker container. To connect to a remote Memgraph instance you need to provide the flag with the IP address or DNS name of the Memgraph instance and the flag with the port number, default .
If you want to connect to your local Memgraph instance, you can use the following command on Linux host:
If you are using MacOS or Windows, you can use the following command to start :
On MacOS and Windows, is a special DNS name that resolves to the host machine from a container. It is necessary to use it to connect to a Memgraph instance running on the host machine.
Execute Cypher queries
After the client has started, it should present a command prompt similar to:
At this point, it is possible to execute Cypher queries against a running Memgraph database instance.
If you are new to Cypher, check out how to query the database.
Query execution time
Upon successful execution of a query, Memgraph will return the execution time.
To get a breakdown of the execution time, set the flag to .
It will extend the information about the execution time with the following data:
The values show:
- COST estimate - Internal planner estimation on the cost of the query. When comparing two query executions, an order of magnitude larger COST estimates might indicate the query’s longer execution time.
- PARSING time - Time spent checking if the query is valid and normalizing it for cache.
- PLAN EXECUTION time - Time executing the plan.
- PLANNING time - Time it takes the query planner to create the optimal plan to execute the query.
Configure mgconsole
Below are configurational flags you can use with mgconsole:
Main
Flags
Help
Non-interactive mode
If you want to use interactive mode with a in a docker container, use the following command:
To save the query results in a file, use the following command: