diff --git a/infra/airflow/scripts/generate_neo4j_graph_data.py b/infra/airflow/scripts/generate_neo4j_graph_data.py index 0faafeb..dcf3176 100644 --- a/infra/airflow/scripts/generate_neo4j_graph_data.py +++ b/infra/airflow/scripts/generate_neo4j_graph_data.py @@ -88,6 +88,9 @@ def main(): auth=(DB_USER, DB_PASSWORD)) with driver.session() as session: + # Indexes make relationship MATCH/MERGE fast even with many existing nodes + session.run("CREATE INDEX product_id_idx IF NOT EXISTS FOR (p:Product) ON (p.product_id)") + session.run("CREATE INDEX supplier_id_idx IF NOT EXISTS FOR (s:Supplier) ON (s.supplier_id)") print(f"Generating {TARGET_NODES} product nodes...") print(f"Batch size: {BATCH_SIZE}")