Run statements and inspect their plans

Copy Markdown View Source

Use this guide to read or change data with bound parameters and see how ArcadeDB executes a statement. The default language is Cypher. HTTP also accepts "sql", "gremlin", "graphql", "mongo", and "sqlscript".

Bind values in the statement's language

Use Arcadic.query/4 for reads and Arcadic.command/4 for writes. ArcadeDB rejects writes to the HTTP read endpoint with :not_idempotent. Bolt can execute a write submitted through Arcadic.query/4, so keep effect selection in the calling code.

The default HTTP response contains a list of rows. Arcadic removes top-level @props and preserves record and graph identity keys such as @rid, @type, @cat, @in, and @out. Use serializer: "graph" to get separate vertex and edge lists as described by Arcadic.Result.

{:ok, users} =
  Arcadic.query(conn, "MATCH (u:User {name: $name}) RETURN u", %{"name" => name})

{:ok, rows} =
  Arcadic.query(conn, "SELECT FROM User WHERE name = :name", %{"name" => name}, language: "sql")

Use $name for Cypher and :name for SQL. A Cypher placeholder in SQL can bind to null, while a SQL placeholder in Cypher produces a parse error. Arcadic.query!/4 and Arcadic.command!/4 return the result or raise. See Arcadic.Error and Arcadic.TransportError for the error contracts.

Arcadic.command_async/4 returns :ok when the HTTP server accepts a command for processing. Acceptance does not confirm the write finished.

Inspect a plan

Arcadic.explain/4 returns a plan without executing the statement. Arcadic.profile/4 executes the statement and adds runtime measurements. Both return a map with a human-readable :plan, a transport-specific :plan_tree, and :rows. The rows list is empty for explain/4.

{:ok, plan} = Arcadic.explain(conn, "MATCH (u:User) RETURN u")
{:ok, profiled} = Arcadic.profile(conn, "MATCH (u:User) RETURN u")

Pass the original statement without an EXPLAIN or PROFILE prefix. Plan calls take :language and :timeout. See Arcadic for supported options on other statement entry points.