I have a simple query and it takes 240ms - 280ms to execute.
In my shell on my capella dashboard it takes 3ms.
config:
import {
Bucket,
Cluster,
Collection,
connect,
GetResult,
Scope,
} from 'couchbase';
import * as Sentry from '@sentry/node';
export const cbdb = async () => {
try {
const cluster: Cluster = await connect('couchbases://cb.xxx.cloud.couchbase.com', {
username: 'xxxx',
password: 'xxxxx!',
// Use the pre-configured profile below to avoid latency issues with your connection.
configProfile: "wanDevelopment",
});
const bucket: Bucket = cluster.bucket('bucket');
const scope: Scope = bucket.scope('scope');
console.log('COUCHBASE CONNECTED');
return scope;
} catch(e) {
console.log('CBB')
console.log(e);
Sentry.captureException(`${e}`);
return null;
}
};
server.ts
import express from 'express';
import { cbdb } from './config/db';
const app = express();
const db = await cbdb();
app.get('/', async(req, res) => {
try {
console.time("concatenation");
const d = await db?.query('SELECT click FROM products WHERE META().id = $1', {
parameters: ['products1']
});
console.timeEnd("concatenation");
res.send('hello');
} catch(e) {
console.log(e);
res.send(e);
}
})
const port = process.env.PORT || 3000;
const server = app.listen(port, async () => {
console.log(`server started on port: ${port}`);
});
I take more then one execution and all query takes 240-280ms. What I am doing wrong ? I use capella trial. In my capella UI dashboard when I execute a query it takes 4ms