How to support generating a massive list of potentially unique merge queries

Hi,

I've been digging around for a while and haven't found something suitable for the usecase that I'm using neo4j for. I need to generate potentially a massive list (tens of thousands) of merge queries. I've gotten things into the format of a list of queries and params </{query, param}>. apoc.periodic.iterate seems to be similar to what I need but the issue with that is that iterate expects the same cypherAction for each item. I need something performant that I can iterate through and perform a different action for each item. It would also be great if the procedure also handled rollback. Does this exist?

Ideally something that looks like
</
UNWIND $data as data
CALL apoc....(
data,
data.query + data.params,
{ batchSize:1000 }
)

You can possibly call apoc.cypher.run within apoc.periodic.iterate or even just use an UNWIND and then call apoc.cypher.run on your input data.

Thank you! That was exactly what I needed. This worked perfectly

CALL apoc.periodic.iterate(
"UNWIND $data as row RETURN row",
"CALL apoc.cypher.runWrite(row.query, row.params) YIELD value RETURN value",
{batchSize: 1000, parallel: false, batchMode: "SINGLE", params: { data: $queries }}
)

1 Like