elliott
elliott
CDCloudflare Developers
Created by elliott on 7/6/2024 in #hyperdrive
Pgjs perf investigation
I should add I'm getting the cache miss info from the Cloudflare Hyperdrive dashboard for this connection
33 replies
CDCloudflare Developers
Created by elliott on 7/6/2024 in #hyperdrive
Pgjs perf investigation
Hey apologies for slow reply. 1. Yes same user id used on all queries: 123e4567-e89b-12d3-a456-426614174000 2. Config ID: cab7a8666f1d41fa8ddd730463da0f48 3. Version of postgres.js is 3.4.4 4. Snippet below:
app.get('/users/:userId', async (c) => {
const userId = c.req.param('userId');
const sql = postgres(c.env.HYPERDRIVE.connectionString, { prepare: true });
const [user]: [User?] = await sql`SELECT * FROM platform.users WHERE id = ${userId}`;
if (!user) {
throw new Error('Handle error');
}
return c.json(user);
});
app.get('/users/:userId', async (c) => {
const userId = c.req.param('userId');
const sql = postgres(c.env.HYPERDRIVE.connectionString, { prepare: true });
const [user]: [User?] = await sql`SELECT * FROM platform.users WHERE id = ${userId}`;
if (!user) {
throw new Error('Handle error');
}
return c.json(user);
});
Database is an RDS instance in region: eu-west-1 With these settings I get 100% cache miss (and a greater latency than when prepare is set to false).
33 replies