Faster way to add many edges to particular node?

I have a query being built up through python that looks something like this:

for url in urls:
    q = '''Match (u:User) Where u.id=18284 
           Merge (:Url {{ url:"{url}" }})<-[:CONTAINS_URL]-(u)'''
    tx.run(q)

It seems wasteful to have to Match on the user over and over again. Is there a way to match it once and add all the corresponding url edges in some sort of batch?

The most easy way would to pass in an array parameter and use UNWIND:

tx.run("MATCH (u:User{id:$id}) 
   WITH u 
   UNWIND $urls as url 
   MERGE (:Url{url:url})<-[:CONTAINS]-(u)", 
   id=18284, urls=urls)

Note you're passing named parameters to tx.run. Those will be resolved using the $ notation in your cypher string.