Skip to content

The JavaScript driver is about 4 times slower than the C# one #1223

Open
@AFatNiBBa

Description

@AFatNiBBa

Bug Report

The JavaScript driver is about 4 times slower than the C# one, but the query takes the same amount on the database side.
It's the fact alone that one is written in C# enough to justify this big increase in execution times?

My code

JavaScript

async function execute(pass: string) {
  const db = driver("bolt://localhost:7687", auth.basic("neo4j", pass));

  try
  {
    console.time("query");
    const cypher = "MATCH (master:Cont_SCH_Master)-[:HAS]->(x:Cont_SCH) RETURN master, collect(x) as details";
    const res = await db.executeQuery(cypher, undefined, { database: "neo4j", routing: "READ" });
    console.timeEnd("query");
    console.log(res.summary);
    return res.records;
  }
  finally { await db.close(); }
}

C#

static async Task<List<IRecord>> Execute(string pass)
{
  await using var driver = GraphDatabase.Driver("bolt://localhost:7687", AuthTokens.Basic("neo4j", pass));
  await using var session = driver.AsyncSession();

  var sw = Stopwatch.StartNew();
  try
  {
    var res = await session.RunAsync("MATCH (master:Cont_SCH_Master)-[:HAS]->(x:Cont_SCH) RETURN master, collect(x) as details");
    return await res.ToListAsync();
  }
  finally
  {
    Console.WriteLine($"query: {sw.Elapsed.TotalMilliseconds} ms");
  }
}

Timings

JavaScript
image

C#

query: 11670,4118 ms

My Environment

Javascript Runtime Version: Edge 128.0.2739.67
Driver Version: 5.24.1
Neo4j Version and Edition: 5.23.0 (enterprise)
Operating System: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions