PostgreSQL DBA
2.02K subscribers
141 photos
1 video
20 files
250 links
Sharing knowledge about postgresql database
Download Telegram
Beyond indexing, several query optimization techniques can significantly improve performance.
CREATE TABLE orders (
order_id SERIAL PRIMARY KEY,
customer_id INTEGER,
order_date DATE,
order_total NUMERIC
) PARTITION BY RANGE (order_date);

CREATE TABLE orders_y2023 PARTITION OF orders
FOR VALUES FROM ('2023-01-01') TO ('2024-01-01');

CREATE TABLE orders_y2024 PARTITION OF orders
FOR VALUES FROM ('2024-01-01') TO ('2025-01-01');

-- Add an index to each partition
CREATE INDEX idx_orders_y2023_customer_id ON orders_y2023 (customer_id);
CREATE INDEX idx_orders_y2024_customer_id ON orders_y2024 (customer_id);
Configuration Parameters
1
Patroni is a widely used solution for managing PostgreSQL high availability. It provides a robust framework for automatic failover, cluster management, and operational simplicity in PostgreSQL environments. 

https://www.cybertec-postgresql.com/en/patroni-cascading-replication-with-stanby-cluster/