/memgraph:memgraph-indexes-and-constraintsfrom memgraph
Create and manage Memgraph indexes, constraints, and enums. Covers label, composite, edge, point, text, vector indexes, and schema enforcement.
Ships in memgraph. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Indexes are NOT created automatically unless explicitly enabled via flags. Adding an index speeds reads but slows writes and uses extra memory.
| Type | Create | Drop |
|---|---|---|
| Label | CREATE INDEX ON :Label; | DROP INDEX ON :Label; |
| Label-property | CREATE INDEX ON :Label(prop); | DROP INDEX ON :Label(prop); |
| Composite | CREATE INDEX ON :Label(p1, p2); | DROP INDEX ON :Label(p1, p2); |
| Descending | CREATE INDEX ON :L(p) WITH CONFIG {"order": "DESC"}; | DROP INDEX ON :L(p) WITH CONFIG {"order": "DESC"}; |
| Edge-type | CREATE EDGE INDEX ON :TYPE; | DROP EDGE INDEX ON :TYPE; |
| Edge-type property | CREATE EDGE INDEX ON :TYPE(prop); | DROP EDGE INDEX ON :TYPE(prop); |
| Global edge property | CREATE GLOBAL EDGE INDEX ON :(prop); | DROP GLOBAL EDGE INDEX ON :(prop); |
| Point | CREATE POINT INDEX ON :L(prop); | DROP POINT INDEX ON :L(prop); |
| Text | CREATE TEXT INDEX name ON :L; | DROP TEXT INDEX name; |
| Vector | CREATE VECTOR INDEX name ON :L(prop) WITH CONFIG {...}; | DROP VECTOR INDEX name; |
| Drop all | - | DROP ALL INDEXES; |
Show: SHOW INDEX INFO; or SHOW INDEXES;
CREATE INDEX ON :Person(age);
Creating a label-property index does NOT create a label index - create both if needed. Best performance on high-cardinality properties (unique IDs, names). Avoid on booleans or low-cardinality fields.
CREATE INDEX ON :Person(name, occupation);
Follows the leftmost prefix rule:
| Query filters | Uses index? |
|---|---|
p0 | Yes |
p0, p1 | Yes |
p0, p1, p2 | Yes |
p0, p2 (skip p1) | Yes + extra filter |
p1 only | No |
p2 only | No |
Put highest-cardinality property first.
CREATE INDEX ON :Person(age) WITH CONFIG {"order": "DESC"};
Optimizes ORDER BY prop DESC and top-N queries. ASC and DESC can coexist on
the same label+property. Only supported in IN_MEMORY_TRANSACTIONAL.
Dropping without config removes both ASC and DESC variants.
CREATE INDEX ON :Project(delivery.status.due_date);
Must use WHERE clause to query - inline map matching won't use the index:
-- Wrong (compares entire map):
MATCH (p:Project {delivery: {status: {due_date: date("2025-06-04")}}}) RETURN p;
-- Correct:
MATCH (p:Project) WHERE p.delivery.status.due_date = date("2025-06-04") RETURN p;
Require --storage-properties-on-edges=true.
CREATE EDGE INDEX ON :KNOWS;
CREATE EDGE INDEX ON :KNOWS(since);
CREATE GLOBAL EDGE INDEX ON :(weight);
CREATE POINT INDEX ON :Location(coords);
MATCH (n:Location) WHERE point.distance(point({x:1, y:1}), n.coords) < 1000 RETURN n;
MATCH (n:Location) WHERE point.withinbbox(n.coords, point({x:0, y:0}), point({x:10, y:10})) RETURN n;
USING INDEX :Person(name)
MATCH (n:Person {name: "Alice", gender: "F"}) RETURN n;
Run once after indexes are created and data is loaded:
ANALYZE GRAPH;
ANALYZE GRAPH ON LABELS :Person, :City;
ANALYZE GRAPH DELETE STATISTICS;
Calculates property value distribution for optimal index and MERGE selection. Statistics persist via snapshots/WAL.
Only in IN_MEMORY_TRANSACTIONAL. Flags:
--storage-automatic-label-index-creation-enabled--storage-automatic-edge-type-index-creation-enabledLabel, label-property, composite, and edge indexes are created concurrently.
Brief READ ONLY during registration phase (waits for pending writes), then
background indexing proceeds while reads and writes resume.
CREATE CONSTRAINT ON (n:Employee) ASSERT EXISTS (n.first_name);
DROP CONSTRAINT ON (n:Employee) ASSERT EXISTS (n.first_name);
SHOW CONSTRAINT INFO;
One label + one property at a time.
CREATE CONSTRAINT ON (n:Employee) ASSERT n.email IS UNIQUE;
CREATE CONSTRAINT ON (n:Employee) ASSERT n.name, n.address IS UNIQUE;
DROP CONSTRAINT ON (n:Employee) ASSERT n.email IS UNIQUE;
Multi-property: same name OR same address is allowed; same name AND address is forbidden. Uniqueness constraints do NOT create indexes - add them separately.
CREATE CONSTRAINT ON (n:Person) ASSERT n.name IS TYPED STRING;
CREATE CONSTRAINT ON (n:Person) ASSERT n.age IS TYPED INTEGER;
DROP CONSTRAINT ON (n:Person) ASSERT n.name IS TYPED STRING;
Supported types: NULL, STRING, BOOLEAN, INTEGER, FLOAT, LIST, MAP,
DURATION, DATE, LOCALTIME, LOCALDATETIME, ZONEDDATETIME, ENUM, POINT.
Only one type constraint per label-property pair.
DROP ALL CONSTRAINTS;
Constraints are checked optimistically on commit. In multi-query explicit transactions, intermediate violations are allowed as long as the final state satisfies all constraints.
CREATE ENUM Status VALUES { Good, Okay, Bad };
SHOW ENUMS;
ALTER ENUM Status ADD VALUE Excellent;
ALTER ENUM Status UPDATE VALUE Bad TO Poor;
Use in queries:
CREATE (:Machine {status: Status::Good});
MATCH (n:Machine) WHERE n.status = Status::Bad RETURN n;
RETURN ToEnum("Status", "Good");
RETURN ToEnum("Status::Okay");
Less memory and faster comparison than string properties.
Index/constraint/enum DDL requires exclusive (unique) access - briefly blocks other queries during execution. Normal Cypher queries use shared access.
Timeout for write access during index creation:
SET DATABASE SETTING 'storage.access_timeout_sec' TO '30';
--storage-properties-on-edges=truememgraph-database-configuration)ANALYZE GRAPH once after data load for optimal index selectionDROP INDEX without config drops both ASC and DESC variantsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
memgraph, indexes, constraints, enums, graph-database, cypher
memgraph@memgraph is listed by memgraph/marketplace — review the source before installing
npx claudepluginhub memgraph/marketplace --plugin memgraph14 skills in this plugin
/memgraph-brand-uiGenerate apps, demos, dashboards, diagrams, landing pages, and any visual output that looks like it belongs in the Memgraph product family. Use whenever producing UI, visual artifacts (Mermaid, SVGs, charts), Lab-style admin tools, internal dashboards, feature splash pages, or embeddable widgets for Memgraph engineers./memgraph-cpp-query-modulesDevelop custom query modules in C++ for Memgraph graph database. Use when creating high-performance graph algorithms, procedures (ProcedureType::Read/Write), or functions using the mgp.hpp C++ API. Covers compilation, memory management, graph traversal, and module deployment./memgraph-cypher-syntaxWrite Cypher queries for Memgraph, including Memgraph-specific extensions like deep path traversals (BFS, DFS, WSP, ASP, KSP with filter/weight lambdas), text and vector search, parallel execution, and CALL subqueries. Use when the user asks to write, fix, or optimize a Cypher query for Memgraph, or asks about Cypher syntax differences between Memgraph and Neo4j./memgraph-database-configurationConfigure Memgraph triggers, transactions, storage modes, data durability, and memory settings. Use when the user asks about triggers, transaction isolation levels, storage modes (transactional vs analytical), snapshots, WAL, memory limits, data types, or database runtime configuration./memgraph-graph-ragLanguage-agnostic blueprint for building GraphRAG systems with Memgraph and agent tooling. Covers end-to-end architecture, schema design, ingestion, hybrid retrieval, tool contracts, and evaluation. Use when designing GraphRAG platforms that must work across multiple programming languages./memgraph-import-dataImport or migrate data into Memgraph from CSV, Parquet, JSON/JSONL, CYPHERL dumps, relational databases (PostgreSQL, MySQL, SQL Server, Oracle, DuckDB) or Neo4j: choosing between LOAD CSV, cross_database procedures and client-driven batches, preparing indexes and storage mode, ordering nodes before relationships, and verifying counts. Use when the user wants to load, bulk-insert, ingest or migrate data into Memgraph, or an import is slow or failing.Other plugins' skills for the same job