From 967503ec38b9de0ed88b44e35a41f43daf1f4b91 Mon Sep 17 00:00:00 2001 From: Lars-Erik Roald Date: Wed, 26 Jun 2024 22:07:52 +0200 Subject: [PATCH] pool --- src/drizzle/benchmark-pg.ts | 4 +++- src/drizzle/postgres.ts | 2 +- src/orange/benchmark-pg.ts | 4 +++- src/orange/postgres.ts | 2 +- src/prisma/benchmark-pg.ts | 6 ++++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/drizzle/benchmark-pg.ts b/src/drizzle/benchmark-pg.ts index d70bf86..d8e195e 100644 --- a/src/drizzle/benchmark-pg.ts +++ b/src/drizzle/benchmark-pg.ts @@ -14,7 +14,9 @@ async function benchmark() { async function warmup() { //to initate possible lazy loaded pool - await postgres.query.customers.findFirst(); + for (let i = 0; i < 12; i++) { + await postgres.query.customers.findFirst(); + } } async function getRowsWithRelations() { diff --git a/src/drizzle/postgres.ts b/src/drizzle/postgres.ts index d6753f2..c775814 100644 --- a/src/drizzle/postgres.ts +++ b/src/drizzle/postgres.ts @@ -3,7 +3,7 @@ import postgres from "postgres"; import * as schema from './schema'; -export const connection = postgres('postgres://postgres:postgres@postgres/postgres', { max: 1 }); +export const connection = postgres('postgres://postgres:postgres@postgres/postgres', { max: 10 }); export const db = drizzle(connection, { schema, diff --git a/src/orange/benchmark-pg.ts b/src/orange/benchmark-pg.ts index ad3f18b..a1c59d9 100644 --- a/src/orange/benchmark-pg.ts +++ b/src/orange/benchmark-pg.ts @@ -17,7 +17,9 @@ async function benchmark() { async function warmup() { //to initate possible lazy loaded pool - await pg.customers.getOne(); + for (let i = 0; i < 12; i++) { + await pg.customers.getOne(); + } } async function getRowsWithRelations() { diff --git a/src/orange/postgres.ts b/src/orange/postgres.ts index f775b6a..1cacad0 100644 --- a/src/orange/postgres.ts +++ b/src/orange/postgres.ts @@ -1,4 +1,4 @@ import map from './map'; -export default map.postgres('postgres://postgres:postgres@postgres/postgres', { size: 1}); +export default map.postgres('postgres://postgres:postgres@postgres/postgres', { size: 10}); diff --git a/src/prisma/benchmark-pg.ts b/src/prisma/benchmark-pg.ts index 6cd7e82..ab557eb 100644 --- a/src/prisma/benchmark-pg.ts +++ b/src/prisma/benchmark-pg.ts @@ -6,7 +6,7 @@ const ITERATIONS = Number.parseInt(process.env.ITERATIONS); const prisma = new PrismaClient({ datasources: { db: { - url: `${process.env.POSTGRES_URL}?connection_limit=1`, + url: `${process.env.POSTGRES_URL}?connection_limit=10`, }, }, log: [ @@ -30,7 +30,9 @@ async function benchmark() { } async function warmup() { - await prisma.order.findMany({ take: 1 }); + for (let i = 0; i < 12; i++) { + await prisma.order.findMany({ take: 1 }); + } } async function getRowsWithRelations() {