{"datalog_plan": {"patterns": [{"idx": 0, "table": "mentat.datoms_keyword_new", "attribute": "::issue/state", "variables": {"value": "?state", "entity": "?i"}}], "complexity": {"cte": false, "joins": 1, "union_all": false, "aggregates": true}, "predicates": [], "not_clauses": 0, "or_branches": 0, "join_variables": [], "ground_bindings": {}, "where_functions": []}, "explain_plan": "GroupAggregate (cost=534404.93..2168403.62 rows=5 width=64)\n Output: ((':'::text || current_keyword.v)), (count(DISTINCT current_keyword.e))::text\n Group Key: ((':'::text || current_keyword.v))\n InitPlan 1 (returns $0)\n -> Seq Scan on mentat.schema (cost=0.00..1.49 rows=1 width=8)\n Output: schema.entid\n Filter: (schema.ident = ':issue/state'::text)\n -> Gather Merge (cost=534403.44..2103522.12 rows=12975986 width=40)\n Output: ((':'::text || current_keyword.v)), current_keyword.e\n Workers Planned: 5\n Params Evaluated: $0\n -> Sort (cost=533403.37..539891.36 rows=2595197 width=40)\n Output: ((':'::text || current_keyword.v)), current_keyword.e\n Sort Key: ((':'::text || current_keyword.v)), current_keyword.e\n -> Parallel Seq Scan on mentat.current_keyword (cost=0.00..215354.95 rows=2595197 width=40)\n Output: (':'::text || current_keyword.v), current_keyword.e\n Filter: ((current_keyword.store_id = '0'::bigint) AND (current_keyword.a = $0))\nQuery Identifier: 1385496963378190323", "datalog_query": "[:find ?state (count ?i) :where [?i :issue/state ?state]]", "generated_sql": "SELECT CASE datoms0.value_type_tag WHEN 0 THEN datoms0.v_ref::TEXT WHEN 1 THEN datoms0.v_bool::TEXT WHEN 2 THEN datoms0.v_long::TEXT WHEN 3 THEN 'd:' || ('x' || encode(float8send(datoms0.v_double), 'hex'))::bit(64)::bigint::TEXT WHEN 4 THEN to_char(datoms0.v_instant AT TIME ZONE 'UTC', 'YYYY-MM-DD\"T\"HH24:MI:SS.US\"Z\"') WHEN 7 THEN datoms0.v_text WHEN 8 THEN ':' || datoms0.v_keyword WHEN 10 THEN datoms0.v_uuid::TEXT WHEN 11 THEN encode(datoms0.v_bytes, 'hex') ELSE NULL::TEXT END, COUNT(DISTINCT datoms0.e)::TEXT FROM (SELECT e, a, 8::SMALLINT AS value_type_tag, NULL::BIGINT AS v_ref, NULL::BOOLEAN AS v_bool, NULL::BIGINT AS v_long, NULL::DOUBLE PRECISION AS v_double, NULL::TEXT AS v_text, v AS v_keyword, NULL::TIMESTAMPTZ AS v_instant, NULL::UUID AS v_uuid, NULL::BYTEA AS v_bytes, tx, true AS added FROM mentat.current_keyword WHERE store_id = $1) AS datoms0 WHERE datoms0.a = (SELECT entid FROM mentat.schema WHERE ident = $2) AND datoms0.added = true GROUP BY 1"}