Accelerate & Edge — Series 2

Preview — 3 of 10 questions

What do Prisma driver adapters (e.g., @prisma/adapter-pg, @prisma/adapter-neon) provide?

javascript
import { PrismaPg } from '@prisma/adapter-pg';

const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
const prisma = new PrismaClient({ adapter });
AThey let Prisma Client use a JavaScript-native driver (like node-postgres, or a specific serverless-friendly HTTP/WebSocket driver) for the actual database connection, instead of Prisma's own Rust-based query engine handling the connection directly — this decouples "which database client library actually talks to the database" from Prisma's query-building layer, enabling compatibility with edge runtimes, serverless drivers, and connection poolers that the built-in engine doesn't natively support
BDriver adapters only change the SQL dialect Prisma generates; the connection mechanism is unaffected
CDriver adapters are required for every Prisma Client instance, even in standard Node.js server environments
DDriver adapters replace the entire Prisma schema and query builder with a different ORM

What does generator client { engineType = "library" } (vs "binary") control?

javascript
generator client {
  provider   = "prisma-client-js"
  engineType = "library" // or "binary"
}
AengineType determines whether queries execute on the client (library) or the server (binary)
BIt controls whether Prisma's query engine runs as an in-process native library loaded directly into the Node.js process (library, generally faster startup, fewer moving parts) versus a separate binary executable process that Prisma Client communicates with over a local connection (binary, historically the default, useful in certain deployment environments where a separate process is preferred/required)
Clibrary engineType disables the query engine entirely and routes all queries through raw SQL
DengineType only affects prisma generate output formatting, not actual runtime query execution

What does prisma.$metrics.json() provide?

javascript
const metrics = await prisma.$metrics.json();
// {
//   counters: [{ key: 'prisma_client_queries_total', value: 15234, ... }],
//   gauges: [{ key: 'prisma_pool_connections_open', value: 8, ... }],
//   histograms: [{ key: 'prisma_client_queries_duration_histogram_ms', ... }],
// }
AIt returns the full JSON Schema representation of the Prisma data model
B$metrics is only available when using Prisma Accelerate; it does not exist for standard Prisma Client
CIt returns a JSON snapshot of internal Prisma Client runtime metrics — like the number of active/idle connections in the pool, query counts, and query duration histograms — useful for feeding into an observability/monitoring system
DIt returns aggregate business metrics computed from your actual table data, like total user count

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.