Skip to content

Commit

Permalink
pool
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars-Erik Roald committed Jun 26, 2024
1 parent 23b52b3 commit 967503e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/drizzle/benchmark-pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/drizzle/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/orange/benchmark-pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/orange/postgres.ts
Original file line number Diff line number Diff line change
@@ -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});

6 changes: 4 additions & 2 deletions src/prisma/benchmark-pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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() {
Expand Down

0 comments on commit 967503e

Please sign in to comment.