S/02databases

PostgreSQL & Database Performance Engineering

PostgreSQL performance consulting is diagnostic work: we read pg_stat_statements, run EXPLAIN (ANALYZE, BUFFERS) against the queries that actually cost you time, then fix them — indexes, schema, pooling, server configuration. You get the query plans before and after, not a slide deck. The engineer who runs the analysis is the one who ships the fix.

Discuss your taskFirst findings on day one, full report in 3–5 working days, reply within 2 hours

What this solves

Queries that were fast last year

A statement that ran in 40 ms now takes four seconds and the table has only doubled. We pull pg_stat_statements, sort by total time, and read the real plans — that usually names the cause inside a day.

N+1 queries and ORM output

An endpoint issues 300 small queries instead of one join, and no index will save it. We profile the request path, rewrite the offending access patterns, and add the indexes the new plan actually needs.

Connections run out under load

Every app instance opens its own pool, Postgres hits max_connections, and sessions sitting idle in transaction hold locks for minutes. We put pgBouncer in front, size the pools, and bound transaction lifetime.

A migration with a deadline

MySQL, Oracle or SQL Server to PostgreSQL: type mapping, stored procedure rewrites, historical data transfer, then a cutover through logical replication measured in minutes rather than a lost weekend.

Analytics running on the primary

Month-end reporting competes with customer traffic on the same instance. We move it to a read replica, or to ClickHouse or BigQuery when replicas stop being enough, and keep the OLTP schema lean.

Backups nobody has ever restored

A nightly dump on the same host is not a backup. We set up pgBackRest or WAL-G with point-in-time recovery, off-host storage and a restore drill, so you know your real recovery time before you need it.

How the work runs

  1. Free scoping call

    1 day

    Thirty minutes: symptoms, PostgreSQL version, database size, where it runs, managed or self-hosted. You leave with a hypothesis about the cause and an honest estimate. No charge, no obligation.

  2. Access, scoped and logged

    1 day

    We sign an NDA before anything is shared. An anonymised dump or a read-only replica is enough for the audit; production access, if implementation needs it later, is per approved task with every command logged.

  3. Diagnosis

    2–3 days

    pg_stat_statements for the top consumers, EXPLAIN (ANALYZE, BUFFERS) on each of them, then unused and missing indexes, lock contention, autovacuum behaviour, table bloat, and configuration against your actual hardware.

  4. Findings with before/after plans

    1 day

    A prioritised list: what we fix without touching your code, what needs an application change, what needs a schema change. Each item carries the measured plan before and the measured time after.

  5. Implementation

    3–10 days

    Indexes built CONCURRENTLY, schema changes shipped as backwards-compatible versioned migrations with a rollback path, heavy queries rewritten alongside your developers. Production keeps serving throughout.

  6. Verification and handover

    1–2 days

    We re-run the same workload, then hand over the migrations, the written rationale for each change, and a monitoring dashboard with alerts. One month of warranty on everything we shipped.

Stack

Most of this work is PostgreSQL and the tooling immediately around it. We reach for ClickHouse or BigQuery only when analytics genuinely outgrows a read replica, and we will tell you that rather than sell you a second database to operate.

  • PostgreSQL 16
  • pg_stat_statements
  • EXPLAIN (ANALYZE, BUFFERS)
  • pgBouncer
  • Patroni + streaming replication
  • pgBackRest / WAL-G with PITR
  • Logical replication and Debezium
  • Versioned migrations (Flyway, node-pg-migrate)
  • ClickHouse
  • Redis
  • BigQuery
  • Prometheus + Grafana + postgres_exporter

What it costs

Performance audit

from $600 / from 60 000 ₽

Roughly 20 hours at $30/hour: statistics collection, the top 20 queries by total time read plan by plan, index coverage, lock and autovacuum analysis, configuration and backup review. Delivered in 3–5 working days with before/after measurements.

Audit and implementation

from $1,500 / from 150 000 ₽

The audit plus the actual fixes: indexes, rewritten queries, partitioning for large tables, pgBouncer, server tuning, verified measurements. What moves the number is database size, how many query paths are broken, and whether application code has to change.

Schema design or migration

from $2,500 / from 250 000 ₽

A schema designed from scratch for a new product, or a move from MySQL, Oracle or SQL Server to PostgreSQL: type mapping, data transfer, logical replication, cutover, replication and backups on the new setup. Priced on table count and how much logic lives in the database.

Prices are indicative and do not constitute a public offer. The final cost, scope and timeline are fixed in a contract or invoice after we have discussed the task.

Related case study

The KMD CRM was built from an empty database: we designed the schema, and it has since gone through 89 migrations while serving 12+ modules. Access control lives in the data model — 9 roles against 87 permissions — instead of being scattered through application code. It is the same design work we do when a team asks for a schema rebuilt for scale.

Read the KMD case

Frequently asked questions

How much does PostgreSQL consulting cost?
The hourly rate is from $30, and the fixed-scope audit is from $600 — about 20 hours of work. Implementation engagements start from $1,500 and migrations from $2,500. Ongoing support runs from $400 per month with a named engineer. Payment is 50% upfront and 50% on acceptance, and the scoping call costs nothing.
Can you fix slow queries without rewriting our application?
Often, yes. A large share of slow-query problems is solved with indexes, planner statistics, configuration and pooling — none of which touch your code. The exceptions are N+1 access patterns, missing pagination, and transactions held open across external HTTP calls. The report labels every finding as one or the other, so you know upfront what lands on your developers.
How long does a database performance audit take?
3–5 working days from the moment we have access to data. The top consumers usually surface on day one and we send those immediately rather than sitting on them until the report is finished. Implementation adds 3 to 10 working days depending on how much of the schema and application code has to move.
Can you migrate us from MySQL to PostgreSQL without downtime?
Close to it. The pattern is logical replication: we stand up PostgreSQL, replicate from MySQL while both run, verify row counts and application behaviour against the new database, then cut over. The write-freeze window is typically minutes. Historical data and stored logic are moved before that point, not during it.
Do you work with managed databases like RDS, Aurora, or Cloud SQL?
Yes — most of our audits run on managed instances. The constraint is no superuser and no OS access, so we work through pg_stat_statements, parameter groups and the provider's own metrics. Query, index and schema work is unaffected by that. Where a fix would need an extension your provider does not offer, we say so and propose an alternative.
What access do you need to get started?
An anonymised dump or a read-only replica, plus pg_stat_statements output and your current configuration. That covers the entire audit. Production credentials are not required to begin, and if implementation needs them later, access is granted per approved task with every command logged. The NDA is signed before anything is shared.
Can you help us prepare for a traffic spike?
Yes. We load-test a copy at the multiple you expect, find what breaks first — usually connections, a lock, or one unindexed query — and fix it before the date. Read replicas, pooling and caching go in where the test says they are needed, along with dashboards and alerts so you can watch the system during the event rather than reconstruct it afterwards.
Do you offer ongoing DBA support or only one-off projects?
Both. A one-off audit or migration is the usual entry point; after that many clients move to a monthly retainer from $400 with a named engineer who already knows the schema. The retainer covers monitoring, migration review, capacity planning and being reachable when something breaks. Every project also carries one month of free bug fixes.

Tell us what's slow

Send the symptoms, your PostgreSQL version and roughly how large the database is. You get a reply within 2 hours during business hours, and the scoping call is free.

Discuss your task
PostgreSQL Performance Consulting — Corexy