Why is a test node.js app slow compared to running a query in the Astra CQL console?


Author: localdata01

Originally Sourced from: https://stackoverflow.com/questions/67862855/why-is-a-test-node-js-app-slow-compared-to-running-a-query-in-the-astra-cql-cons

I made an test account in datastax (https://astra.datastax.com/) and want to test cassandra.

In there homepage is an cqlsh console. If I select datas is goes very fast maybe 1ms.

If I use it with nodejs and cassandra driver it takes 2-3 seconds. And I have only ONE row.

Why it takes time? Its my code fault?

const { Client } = require("cassandra-driver");

async function run() {
  const client = new Client({
    cloud: {
      secureConnectBundle: "secure-connect-weinf.zip",
    },
    keyspace: 'wf_db',
    credentials: {
      username: "admin",
      password: "password",
    },
  });

  await client.connect();

  // Execute a query
  const rs = await client.execute("SELECT * FROM employ_by_id;");
  console.log(`${rs}`);

  await client.shutdown();
}

// Run the async function
run();