How to use `analyze()`?

In the documentation link here there is a mention of analyze() function. Suppose I have the following query.
match
$book isa paperback, has isbn-13 "9780446310789";
$line isa order-line (order: $order, item: $book);
delivery (deliverer: $courier, delivered: $order, destination: $address);
fetch {
"id": $order.id,
"quantity": $line.quantity,
"status": $courier.name,
"address": $address.street,
};
match
$book isa paperback, has isbn-13 "9780446310789";
$line isa order-line (order: $order, item: $book);
delivery (deliverer: $courier, delivered: $order, destination: $address);
fetch {
"id": $order.id,
"quantity": $line.quantity,
"status": $courier.name,
"address": $address.street,
};
What would be the correct syntax to run analyze() on this query?
2 Replies
krishnan
krishnan2d ago
The analyze feature is currently only available in the HTTP API. If you're using one of our GRPC drivers (rust, java, python) it may take another week (or two) and will be in 3.6.0. A request is almost identical to the /v1/transactions/TRANSACTION_ID/query (docs here) - i.e., You open a transaction, get the transaction ID and send a POST request to /v1/transactions/TRANSACTION_ID/analyze with a JSON body :

{
"query": "match ...",
}

{
"query": "match ...",
}
The response format is currently only documented in the HTTP driver structure: https://github.com/typedb/typedb-driver/blob/a56654ca8dafbebdc6d2d5492ee05ef70557c7c3/http-ts/src/response.ts#L94 We'll be adding documentation when analyze is added to the GRPC drivers.
rajivranganath
rajivranganathOP12h ago
Thanks for the reply. I got the following response https://gist.github.com/rajivr/60a562febe4fbb9e3283934775aa4ae9 I was wondering if there was someway to visualize what is happening here, perhaps something similar to https://explain.dalibo.com/plan/269f50c8gbc7baa3 ?
Gist
analyze_formatted.json
GitHub Gist: instantly share code, notes, and snippets.
Aggregate with four joins explain.dalibo.com
Visualizing and understanding your PostgreSQL execution plans made easy.

Did you find this page helpful?