PostgreSQL Tuning: Configuration, Indexes, Replication, Backups

Professional **PostgreSQL tuning** is essential for high‑load web applications. Our **PostgreSQL configuration** and optimization service ensures stable performance. When your web project grows beyond a few thousand requests per minute, PostgreSQL often becomes the bottleneck. Incorrect configuratio

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1419
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1287
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    983
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1245
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    983
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    998

Professional PostgreSQL tuning is essential for high‑load web applications. Our PostgreSQL configuration and optimization service ensures stable performance. When your web project grows beyond a few thousand requests per minute, PostgreSQL often becomes the bottleneck. Incorrect configuration leads to slow queries, data loss, and downtime. Sluggish report generation and endless UI loading are typical symptoms. Tuning indexes and connection pooling solves these issues. We tune PostgreSQL so you can forget about databases and focus on your business. With over 5 years of experience and 50+ successful projects, we guarantee stable database performance. Typical tuning costs range from $500 to $3000, and clients see 3–5x query speed improvements. One client saved over $8,000 annually by migrating from Oracle to PostgreSQL with our tuning. Our team of certified specialists ensures professional PostgreSQL tuning.

For example, a recent project: an online store with a catalog of 100,000 products. After tuning indexes and implementing pgBouncer, API response time dropped from 2 seconds to 300 ms, and CPU load decreased threefold. This allowed the client to scale on existing hardware without extra cost.

Why choose PostgreSQL for web applications?

PostgreSQL is not just a relational database. It supports JSONB for flexible schemas, full‑text search, complex queries with window functions, and extensions like PostGIS. For startups and enterprise projects, it's a choice that pays off under load. PostgreSQL handles JSONB 2–3 times faster than MySQL, and its indexing capabilities surpass many commercial DBMS. Migrating from Oracle to PostgreSQL can save significantly on licensing costs. If you need reliability and scalability, PostgreSQL with proper tuning is the answer.

Our PostgreSQL Tuning Process: Step‑by‑Step

Our process includes these steps:

  1. Audit – review current configuration, load, and slow queries.
  2. Installation – set up PostgreSQL and pgBouncer on Ubuntu.
  3. Configuration – adjust parameters for your hardware.
  4. pgBouncer Setup – configure connection pooling.
  5. Index Optimization – create and maintain efficient indexes.
  6. Replication and Backups – set up streaming replication and WAL archiving.
  7. Monitoring – implement slow query logging and alerts.

Let's dive into the key steps.

Installation and Basic Configuration

We install the latest stable PostgreSQL on Ubuntu Server LTS:

apt install -y postgresql-16 postgresql-client-16 systemctl enable postgresql systemctl start postgresql 

Create a database and user:

CREATE USER myapp WITH PASSWORD 'strong_password_here'; CREATE DATABASE myapp_production OWNER myapp; GRANT ALL PRIVILEGES ON DATABASE myapp_production TO myapp; 

What are the key parameters in postgresql.conf?

Default settings are meant for 256 MB RAM. For production, adjust according to actual memory. Comparison for different RAM sizes:

Parameter 4 GB RAM 8 GB RAM 16 GB RAM
shared_buffers 1 GB 2 GB 4 GB
effective_cache_size 3 GB 6 GB 12 GB
work_mem 32 MB 64 MB 128 MB
maintenance_work_mem 256 MB 512 MB 1 GB
max_connections 100 200 400

Example config for 8 GB (16 GB values commented):

shared_buffers = 2GB #shared_buffers = 4GB work_mem = 64MB #work_mem = 128MB maintenance_work_mem = 512MB #maintenance_work_mem = 1GB checkpoint_completion_target = 0.9 wal_buffers = 64MB #wal_buffers = 128MB max_worker_processes = 8 #max_worker_processes = 16 max_parallel_workers_per_gather = 4 #max_parallel_workers_per_gather = 8 max_parallel_workers = 8 #max_parallel_workers = 16 shared_preload_libraries = 'pg_stat_statements' 

When is pgBouncer necessary?

Direct connections to PostgreSQL are expensive: each spawns a separate process. pgBouncer multiplexes them, reducing the number of connections by 5–10 times. This is critical for high‑load applications with hundreds of concurrent connections. We configure the pool:

[databases] myapp_production = host=127.0.0.1 port=5432 dbname=myapp_production [pgbouncer] listen_port = 6432 pool_mode = transaction default_pool_size = 25 max_client_conn = 1000 

Indexes and Partitioning

Query optimization starts with proper indexes. We use partial and composite indexes, GIN for JSONB, full‑text search. For large tables, we partition by month using pg_partman. Examples:

CREATE INDEX CONCURRENTLY idx_orders_user_id ON orders(user_id); CREATE INDEX CONCURRENTLY idx_products_category_price ON products(category_id, price) WHERE deleted_at IS NULL; CREATE INDEX CONCURRENTLY idx_articles_search ON articles USING gin(to_tsvector('russian', title || ' ' || body)); 
Index type When to use Example
B-tree Sorting, ranges, exact matches id, email
GIN Array components, JSONB, full‑text search tags, metadata
GiST Geodata, full‑text (less precise) coordinates, tsquery

On one project (a financial system), we accelerated monthly report generation from 30 seconds to 500 milliseconds using partial indexes.

Identifying Slow Queries

We enable pg_stat_statements to collect statistics. Monitoring reveals the top‑10 queries by execution time. For instance, on a project we found that replacing a full table scan with an index lookup cut report time from 10 seconds to 500 ms. We also regularly check unused indexes via pg_stat_user_indexes. PostgreSQL official documentation recommends pg_stat_statements for performance monitoring.

Replication and Backups

We set up streaming replication (hot standby) and WAL archiving to S3 using WAL‑G. Regular logical backups with pg_dump. This ensures point‑in‑time recovery in case of failure. WAL‑G is a modern backup tool recommended by the PostgreSQL community.

What's Included in the Work

  • Audit of current configuration and load
  • Installation of PostgreSQL + pgBouncer optimized for your server
  • Index and partitioning optimization
  • Replication setup (hot standby) and automated backups
  • Slow query monitoring and unused index detection
  • Documentation of all settings and team training
  • 30‑day warranty on completed work
  • Deliverables: configuration files, monitoring scripts, backup automation, training session
Detailed benefitsOur tuning improves performance by 3-5x and reduces server load, saving on hardware costs.

Estimated Timelines and Costs

  • Installation and basic tuning: 1–2 days (from $500)
  • pgBouncer, replication, and monitoring setup: 2–3 days (from $1000)
  • Migration of existing database with hot standby and automated backups: 3–5 days (from $2000)

Cost is determined after an audit. A typical project ranges from $500 to $3000 depending on complexity.

Consult with our PostgreSQL tuning engineer. We will assess your project and propose the optimal solution. Request a free audit of your PostgreSQL today.

Additional resources: PostgreSQL Documentation