Slow merge and match when I use unwind

Hello,

when I run this code

call apoc.load.jsonParams(uri, options,null)

YIELD value AS listing

MERGE (l:Listing{cid:listing.results[0].listing_id})

it takes 24s to done although I created indexes on that . when I run MERGE (l:Listing{cid:}) as normal query it takes only 1 ms

any idea ?

When I am not using apoc it works with indexes and when I use apoc it hits on all node (doesn't use indexes)

How long does it take to run just the json request?

call apoc.load.jsonParams(uri, options,null)

YIELD value AS listing

return *

Thanks for your response
it takes 5 ms

That is very fast. How about you run the following:

call apoc.load.jsonParams(uri, options,null)
YIELD value AS listing
MERGE (l:Listing{cid:0})

I am trying to figure out if it is the parsing of the json? Even so, your path is not complicated, so I can't image it taking that long to pull out the value of 'listing.results[0].listing_id'. How complicated is the listing json? Can you share it?

I tried it without apoc by creating variable and works quickly

like that :

with ['lst_00000355','lst_00000034b965'] as results
UNWIND results as row
MERGE(l:Listing{clid:row})

but when I use it with apoc

it becomes too slow

json sample : {

key1:"some value"

results: [

{

"listing_id" : 'da312312',

"price_id" : 'prc_231451'

}

]

}

and I use results only .

Something seems very off. I used the apoc method to pull orders from a Shopify site I have and then pull out some data from the response. The json is fairly large and the response was instantaneous.

can u please show the code of that ?

Here it is, but I had to remove my api key information, so you will not be able to call it and get back a response.

call apoc.load.jsonParams('https://xxxx:@yyyy.myshopify.com/admin/api/2021-01/orders.json?fields=created_at,id,name,note_attributes,line_items,customer,tags,shipping_address,shipping_lines,order_status_url,financial_status,fulfillment_status,note,source_name,total_line_items_price,total_tax,total_price,total_discounts&status=open&financial_status=paid,pending&fulfillment_status=partial,null&limit=250',{},null) yield value
return value.orders[9].order_status_url

Thanks a lot

we solved it by creating unique constraints :slightly_smiling_face:

That would speed up the merge, since it will also create an index.

Great you got it working.