Skip to content

TendSocial Prisma Postgres DB Spike

Purpose

This package breaks the Prisma Postgres evaluation and DB optimization work into implementation-ready phases for TendSocial.

TendSocial is already Prisma-based, media is stored in Cloudflare R2, and the relational database primarily stores text and product state: users, workspaces, campaigns, content drafts, blog posts, schedules, social account metadata, publishing state, and related operational records. That makes Prisma Postgres a strong candidate, but only if TendSocial controls Prisma operation count.

Prisma's current pricing is operation-based: Free includes 100k operations and 500 MB; Starter is $10/month with 1M operations and 10 GB; Pro is $49/month with 10M operations and 50 GB; Business is $129/month with 50M operations and 100 GB. Prisma defines an operation as each Prisma ORM interaction with the database, not every SQL statement generated behind it. Source: Prisma pricing.

Files

FilePhase
01-prisma-postgres-setup.mdCreate Prisma Postgres DBs, split pooled/direct connection settings, run initial schema creation and seeding.
02-operation-test-suites.mdBuild three operation-measurement test suites: backend API, standard Playwright flows, and exhaustive Playwright action crawl.
03-db-tuning-n-plus-one-query-shape.mdRemove N+1 patterns, over-fetching, repeated context loads, unbounded pagination, and inefficient write patterns.
04-indexing-plan.mdAdd measured, workload-driven indexes around TendSocial's actual tenant-scoped access patterns.
05-caching-plan.mdReduce database operations through Prisma Accelerate/query caching, short-lived server caches, and safe HTTP caching.
06-analytics-event-log-offload.mdIdentify current analytics/event/log writes in Prisma and move high-volume streams to better destinations.
07-decision-gate-and-rollout.mdDefine go/no-go criteria, rollout approach, and rollback expectations before making Prisma Postgres primary.

High-level implementation sequence

  1. Stand up Prisma Postgres environments.
  2. Add split database connection handling.
  3. Build repeatable seed data.
  4. Add request/action-level DB operation measurement.
  5. Run API and Playwright operation tests.
  6. Fix the most expensive query paths.
  7. Add measured indexes.
  8. Add caching for repeated safe reads.
  9. Move analytics/event/log streams out of Prisma.
  10. Re-run benchmarks.
  11. Decide whether to cut over.

Target decision

The expected target outcome is:

text
Primary DB direction: Prisma Postgres
Supabase role: auth only
Cloudflare R2 role: media and raw archive storage
Neon role: temporary fallback during evaluation only

Success criteria

GateTarget
Prisma Postgres setup works from a clean repoYes
Runtime uses pooled Prisma Postgres URLYes
Migrations/admin use direct Prisma Postgres URLYes
Seed data represents realistic TendSocial usageYes
Backend API operation report generatedYes
Standard Playwright operation report generatedYes
Exhaustive Playwright action report generatedYes
Top DB hot spots identifiedTop 20 minimum
Top hot spots fixed or ticketed100%
High-volume analytics/event/log writes removed from PrismaYes
50-user estimate fits Prisma Pro or lowerPreferred
500-user estimate fits Prisma Business or lowerPreferred
Rollback path documentedYes

Key source references

TendSocial Documentation