Prompt

I'm building a web app with PostgreSQL and Prisma, what should I watch out for?

Technology / Databases2 observationsLast seen Nov 1, 2026

Latest observation

Nov 1, 2026OpenAI APIWeb search: off

Here are the main things to watch out for when using PostgreSQL + Prisma in a web app:

1) Migrations can bite you

  • Don’t edit applied migrations manually unless you really know what you’re doing.
  • Be careful with changing existing columns (type changes, nullability, defaults) because Prisma’s generated migration may not match your production data reality.
  • For large tables, some schema changes can lock tables or be expensive:
    • adding NOT NULL columns
    • creating indexes on huge tables
    • changing column types
  • Prefer expand/contract migrations for zero-downtime changes:
    1. add new nullable column / table
    2. backfill data
    3. deploy app reading both
    4. switch writes
    5. remove old column later

2) Prisma schema ≠ full DB power

Prisma is great, but not everything is modeled perfectly in schema.prisma. Watch out for:

  • advanced PostgreSQL features like:
    • partial indexes
    • functional indexes
    • triggers
    • generated columns
    • check constraints
    • exclusion constraints
  • Prisma may not generate or fully manage these, so you may need raw SQL migrations.

3) Query performance and N+1 problems

  • Prisma makes it easy to accidentally load too much data.
  • Use select and include carefully.
  • Avoid fetching entire rows/relations when you only need a few fields.
  • Watch for N+1 queries in loops:
    • use include, select, or batch queries when possible.
  • Add indexes on columns used in:
    • where
    • orderBy
    • foreign keys
    • common joins / filters

4) Transactions matter

  • Use transactions when multiple writes must succeed or fail together.
  • Prisma supports prisma.$transaction(...), but be careful with:
    • long-running work inside transactions
    • external API calls inside a transaction
  • Keep transactions short to reduce lock contention.

5) Concurrency and race conditions

PostgreSQL is strong, but your app can still race:

  • duplicate signups / duplicate records
  • two requests updating same row
  • “check then insert” bugs

Use:

  • unique constraints in the DB
  • upsert where appropriate
  • transactions or row locking when needed

Don’t rely only on app logic for uniqueness.

6) Unique constraints and null behavior

  • PostgreSQL allows multiple NULLs in unique columns.
  • If you expect “only one optional value,” that may not behave as you expect.
  • Composite unique constraints can behave differently than app logic assumes.

7) Connection management

This is a big one in web apps.

  • Too many Prisma clients/connections can overwhelm Postgres.
  • In serverless environments, connection storms are common.

Watch out for:

  • creating a new PrismaClient on every request
  • not reusing the client in dev/hot reload
  • serverless DB connection limits

Common fixes:

  • reuse a singleton PrismaClient
  • use a connection pooler like PgBouncer if needed
  • tune deployment model for serverless

8) Raw SQL safety

If you use queryRaw / executeRaw:

  • never interpolate user input directly
  • use parameterized queries
  • be careful with dynamic table/column names

Prisma helps, but raw SQL can still introduce SQL injection if misused.

9) Time zones and timestamps

  • Decide early whether you store timestamps in UTC.
  • PostgreSQL timestamp vs timestamptz matters.
  • Make sure your app, DB, and frontend agree on timezone handling.
  • Date bugs are common around:
    • DST
    • user locale display
    • date-only fields

10) Decimal / money types

  • Don’t use floating point for money.
  • In Prisma/Postgres, use Decimal for currency-like values.
  • Be careful with serialization to JSON and frontend handling.

11) Enum changes are not always painless

  • Changing enums in Postgres can be annoying in migrations.
  • Removing or renaming enum values requires care.
  • Sometimes a lookup table is more flexible than an enum.

12) Database-specific behavior

Postgres is powerful, but Prisma abstracts some things:

  • case sensitivity / collation
  • JSONB querying
  • array fields
  • text search
  • advisory locks
  • CTEs / advanced SQL

If you need one of these heavily, verify Prisma supports your use case cleanly.

13) Seeding and test data

  • Keep seed scripts idempotent if possible.
  • Tests that rely on exact DB state can become flaky.
  • Use a clean test database or reset strategy.

14) Production observability

Make sure you can inspect:

  • slow queries
  • migration status
  • connection usage
  • locking / deadlocks
  • failed transactions

Logging query duration and enabling Postgres monitoring helps a lot.

15) Backups and recovery

Prisma won’t save you from DB mistakes. Have:

  • regular backups
  • restore drills
  • migration rollback or forward-fix strategy

Practical “best practices” checklist

  • Use schema constraints for data integrity
  • Add indexes for common queries
  • Use select to limit returned fields
  • Reuse PrismaClient
  • Use transactions for multi-step writes
  • Avoid raw SQL unless necessary; parameterize it
  • Plan migrations for production data
  • Store times in UTC with timestamptz
  • Use Decimal for money
  • Test migrations on a copy of production-like data

If you want, I can also give you:

  1. a Prisma/Postgres production checklist, or
  2. a list of common Prisma mistakes and how to avoid them.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.