C-Weed
C-Weed
DTDrizzle Team
Created by C-Weed on 9/3/2024 in #help
terrible latency with simple sql statements.
main.ts
import { drizzle } from 'drizzle-orm/postgres-js';
import { migrate } from 'drizzle-orm/postgres-js/migrator';
import postgres from 'postgres';
import fs from 'fs';
import { employees } from './schema';
import "dotenv/config"
import { performance } from 'node:perf_hooks';
import { eq } from 'drizzle-orm';

const queryClient = postgres(process.env.DB_URL as string, {
ssl: {
ca: fs.readFileSync(process.env.SSL_ROOT_CERT_PATH as string).toString(),
}
});
const db = drizzle(queryClient);

async function selectAll() {
// const prepared = await db.select().from(employees).prepare("statement_name");
const prepared = await db.select().from(employees).where(eq(employees.firstName, 'John')).prepare("statement_name");
const start = performance.now();
const result = await prepared.execute();
const end = performance.now();
console.log(`Execution time: ${end - start} ms`);
console.log(result);
}

selectAll();
import { drizzle } from 'drizzle-orm/postgres-js';
import { migrate } from 'drizzle-orm/postgres-js/migrator';
import postgres from 'postgres';
import fs from 'fs';
import { employees } from './schema';
import "dotenv/config"
import { performance } from 'node:perf_hooks';
import { eq } from 'drizzle-orm';

const queryClient = postgres(process.env.DB_URL as string, {
ssl: {
ca: fs.readFileSync(process.env.SSL_ROOT_CERT_PATH as string).toString(),
}
});
const db = drizzle(queryClient);

async function selectAll() {
// const prepared = await db.select().from(employees).prepare("statement_name");
const prepared = await db.select().from(employees).where(eq(employees.firstName, 'John')).prepare("statement_name");
const start = performance.now();
const result = await prepared.execute();
const end = performance.now();
console.log(`Execution time: ${end - start} ms`);
console.log(result);
}

selectAll();
>tsx watch app/db/main.ts The above code results in average of 1200ms latency. I have a simple table with 10 entries of dummy data. However, when I do the same statements but in drizzle studio or psql I get <100ms latency. What am I doing wrong?
1 replies
DTDrizzle Team
Created by C-Weed on 9/3/2024 in #help
drizzle studio blocked over http
I'm trying to access drizzle studio over a vps near my database location to test latency. I specified host using https://local.drizzle.studio?port=4322&host=<vps_ip>. However all I get when i navigate to local.drizzle.studio is a "connecting to the drizzle kit on <vps_ip>". When I go to the devtools I see this error appearing over and over again every second: index.js:13800 Mixed Content: The page at 'https://local.drizzle.studio/?host=<vps_ip>' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://<vps_ip>/init'. This request has been blocked; the content must be served over HTTPS.
2 replies