---
title: "If I have read-only tables in Postgres, should I index them heavily?"
description: "Even when writes are off the table, heavily indexing read-only Postgres tables only pays off under certain conditions: table size, query complexity, data cardinality and resource constraints."
url: "https://swe.quest/articles/if-i-have-read-only-tables-in-postgres-should-i-index-them-heavily-cd42f0cfb1d86dc0"
canonical: "https://neon.com/blog/if-i-have-read-only-tables-in-postgres-should-i-index-them-heavily"
source: "Neon"
published: "2024-07-17"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["postgres","performance","sql"]
---

# If I have read-only tables in Postgres, should I index them heavily?

A post on [Neon](https://swe.quest/sources/neon.md), published 2024-07-17, 9 min read, How-to. Original: [https://neon.com/blog/if-i-have-read-only-tables-in-postgres-should-i-index-them-heavily](https://neon.com/blog/if-i-have-read-only-tables-in-postgres-should-i-index-them-heavily)

## Summary

Even when writes are off the table, heavily indexing read-only Postgres tables only pays off under certain conditions: table size, query complexity, data cardinality and resource constraints. Benchmarks show no gain from an index on a 10k-row table, and a simple low-selectivity equality query on 10M rows was actually slower with an index (0.0078s vs 0.0026s). A multi-condition search with a range filter, ORDER BY and LIMIT dropped from 20.8s to 3.4s with indexing. The recommendation is to index columns used in WHERE, JOIN, ORDER BY and GROUP BY for critical queries, favor high-cardinality orderable types over booleans, and account for the disk, memory and CPU cost of extra indexes.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [SQL](https://swe.quest/tags/sql.md) (Languages)

## Prerequisites

- basic SQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- database indexes ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))

## Keywords

PostgreSQL, B-tree, Neon, covering index, composite index

## Related posts

- [Choosing the right Postgres indexes](https://swe.quest/articles/choosing-the-right-postgres-indexes-8f3c9e0e9ee3e588.md): incident.io · 2024-10-25 · Medium · 9 min read · PostgreSQL, Performance engineering, SQL, Observability
  Postgres indexes pay off for frequently run queries that discard most rows they read, need results in a specific order, or must enforce uniqueness.
- [Tips for maximizing your Turso billing allowances](https://swe.quest/articles/tips-for-maximizing-your-turso-billing-allowances-8384b26349c381e4.md): Turso · 2023-08-23 · Medium · 10 min read · SQLite, SQL, Cost optimization, Performance engineering
  Turso bills by rows read, rows written and storage, so queries that scan whole tables or compute aggregates can cost far more row reads than the rows they return.
- [Top 10 best practices tips for ClickHouse](https://swe.quest/articles/top-10-best-practices-tips-for-clickhouse-4df5699bf7bd75dd.md): ClickHouse · 2026-03-26 · Medium · 21 min read · Analytics & OLAP, Performance engineering, Databases, SQL
  Ten practices for getting performance and storage efficiency out of ClickHouse, each measured on a 150M-row Amazon reviews dataset.
- [The side quest that freed 10% of our database](https://swe.quest/articles/the-side-quest-that-freed-10-of-our-database-649662623bb94a1e.md): incident.io · 2026-11-24 · Medium · 13 min read · PostgreSQL, Query engines, Performance engineering, SQL
  A single lateral-join query answering "who's on call for this rotation layer right now" consumed 34% of incident.io's Postgres replica CPU.
- [6 tips to optimize storage costs for your Postgres databases](https://swe.quest/articles/6-tips-to-optimize-storage-costs-for-your-postgres-databases-11da5e875c34786c.md): Neon · 2024-03-15 · Medium · 4 min read · PostgreSQL, Cost optimization, Storage engines
  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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
