Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 8 min read How-to mediumAdept

Performance tips for Neon Postgres

Neon's serverless Postgres follows mostly standard Postgres tuning, plus a few Neon-specific checks. Size compute at roughly 100 connections per GB of RAM, use pooling and autoscaling, then find slow queries with pg_stat_statements and EXPLAIN (ANALYZE, BUFFERS). Fix them with indexes, REINDEX and autovacuum tuning against bloat, and by keeping the local file cache hit ratio (shown in neon_stat_file_cache) above 99%. For faster ingests, batch inserts, drop unused indexes, offload reads to ephemeral read replicas, and test changes safely on a database branch.

Related posts

  • Postgres Support Recap: Investigating Postgres Query Performance

    Neon mediumAdept

    Three starting points for diagnosing slow Postgres queries: use pg_stat_statements to find long-running queries by mean execution time and then EXPLAIN ANALYZE them, check the cache hit ratio (in Neon via the neon_stat_file_cache view, since Neon extends shared buffers with a local file cache), and look for table and index bloat caused by MVCC dead tuples. A hit ratio below 99% suggests the working set doesn't fit in memory, which calls for more shared_buffers or a larger Neon compute. Bloat is reduced with VACUUM, VACUUM FULL or REINDEX, all of which take locks. PgHero, run via Docker, gives a free dashboard alternative.

  • Debug your Postgres from the terminal: a tour of `neon inspect db`

    Neon mediumAdept

    `neon inspect db` adds fourteen read-only Postgres diagnostic subcommands to the Neon CLI, each running one curated query against Postgres statistics and catalog views (table/index sizes, bloat, unused indexes, seq scans, long-running queries, locks, pg_stat_statements outliers and calls, vacuum stats, replication slots, subscriptions). Connections resolve automatically for linked Neon projects, and most commands also work on any Postgres via `--db-url`. Output is bounded and available as JSON or YAML, which makes it safer for agents than raw SQL access. Neon-specific commands report Local File Cache hit rate (aim for 0.99+) and working set versus LFC size to signal when to scale compute, since Neon pins shared_buffers at 128 MB.

  • Dynamically estimating and scaling Postgres’ working set size

    Neon mediumAdept

    Neon autoscales Postgres compute to keep the workload's working set in memory, using a modified HyperLogLog whose register bits are replaced with timestamps so the number of distinct pages accessed can be estimated for any lookback window. A heuristic scans windows from a 5-minute offset up to one hour and treats the point where the estimate jumps sharply as the end of the current workload's plateau. Scaling then projects working set growth to avoid repeated cache evictions. In benchmarks this matched fixed-size compute performance at 30% lower cost, roughly tripled throughput on a bursty pgbench workload, and raised cache hit rate from 30-70% to 100% on a batch workload.

  • Autoscaling in Action: Postgres Load Testing with pgbench

    Neon mediumAdept

    A pgbench load test against Neon serverless Postgres runs a CPU-heavy query, SELECT log(factorial(32000)) / log(factorial(20000)), to trigger autoscaling. On ¼ vCPU the query spends about 1.9 s in planning, because constant folding happens there, so a modest number of concurrent clients is enough to make the compute scale within a ¼–7 CU range. The walkthrough covers the pgbench flags (-f, -c, -T, -P), reading EXPLAIN ANALYZE output and interpreting the results: roughly 6 s average latency, about 5 TPS and a high latency standard deviation.

  • 6 tips to optimize storage costs for your Postgres databases

    Neon mediumAdept

    Six ways to shrink Postgres storage spend: drop unused indexes (found via pg_stat_user_indexes and pg_index), avoid full database copies for dev and staging by using Neon's copy-on-write branching, choose smaller data types like SMALLINT, order columns largest to smallest to cut alignment padding, shorten Neon's history retention window, and tune autovacuum to limit bloat. Shorter retention saves storage but narrows the point-in-time recovery window. For bloat, look in pg_stat_activity for long-running transactions that block autovacuum.

The quest for software engineering knowledge.

Look:
Layout: