EXPLAIN

EXPLAIN

The EXPLAIN statement when used before any N1QL statement, provides information about the execution plan for the statement.

Example:

EXPLAIN SELECT title, genre, runtime FROM catalog.details ORDER BY title

"results": [
   {
     "#operator": "Sequence",
     "~children": [
         {
            "#operator": "Sequence",
            "~children": [
                {
                   "#operator": "PrimaryScan",
                   "index": "#primary",
                   "keyspace": "catalog",
                   "namespace": "default"
                },
                {
                   "#operator": "Parallel",
                   "~child": {
                        "#operator": "Sequence",
                        "~children": [
                             {
                                "#operator": "Fetch",
                                "keyspace": "catalog",
                                "namespace": "default",
                                "projection": "`details`"
                             },
                             {
                                "#operator": "InitialProject",
                                "result_terms": [
                                    {
                                      "expr": "(`details`.`title`)"
                                    },
                                    {
                                      "expr": "(`details`.`genre`)"
                                    },
                                    {
                                       "expr": "(`details`.`runtime`)"
                                    }
                                    ]
                             }
                       ]
                }
                        }
                    ]
                },
                {
                    "#operator": "Order",
                    "sort_terms": [
                        {
                            "expr": "(`details`.`title`)"
                        }
                    ]
                },
                {
                    "#operator": "Parallel",
                    "~child": {
                        "#operator": "FinalProject"
                    }
         }
      ]
    }
]