Tips for maximizing your Turso billing allowances
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. Use EXPLAIN QUERY PLAN to spot full table scans ("SCAN" vs "SEARCH ... USING INDEX") and add indexes only on columns you filter or sort by, since indexes add storage and slow inserts and deletes. For count/sum/avg, maintain precomputed aggregate tables, either in client transactions or automatically with SQLite triggers. This trades cheaper reads for extra writes, so it suits read-heavy tables.
Related posts
- Super charging your ClickHouse queries
ClickHouse mediumAdept
ClickHouse query speed comes mainly from reading less data: a sparse primary index stores one entry per 8192-row granule and lets binary search skip blocks that can't match the WHERE clause. On the 27.6M-row UK property dataset, re-sorting a copy of the table by (town, price) cuts a full scan to 81.92 thousand rows, and optimize_read_in_order removes the in-memory sort and stops early under LIMIT. Projections do the same job automatically, as hidden tables kept in sync with the main table that can use a different sort order or pre-computed aggregates (backed by AggregatingMergeTree). ClickHouse picks the cheapest projection at query time. Raising query-engine parallelism is the third tuning knob.
- Top 10 best practices tips for ClickHouse
ClickHouse mediumAdept
Ten practices for getting performance and storage efficiency out of ClickHouse, each measured on a 150M-row Amazon reviews dataset. Aligning ORDER BY with query filters (low-cardinality columns first) made one query 3x faster and cut scanned data 347x. Right-sized types, no Nullable and LowCardinality(String) doubled query speed and shrank storage. Partitioning is best avoided except for TTL expiry or FINAL on merge engines; monthly partitions slowed one aggregation 46x. The post also covers lightweight versus heavyweight skipping indexes, JSON type hints (38% less storage, 26% faster), and preferring Parquet/ORC for bulk ingestion.
- A simple guide to ClickHouse query optimization: part 1
ClickHouse mediumAdept
Slow ClickHouse queries can be diagnosed with system.query_log (duration, rows read, memory, CPU, cache metrics) and the EXPLAIN statement, illustrated on the NYC Taxi dataset in the ClickHouse Playground. A table created with an inferred schema (all Nullable columns, empty ORDER BY) forces every example query into a full scan of 329 million rows taking over a second and roughly 400–550 MiB of memory. Turning off the filesystem cache makes timings reproducible. The first part of the series then moves to basic optimizations and choosing primary keys so ClickHouse can skip data instead of scanning it.
- Turso v0.4.0
Turso mediumAdeptTurso v0.4.0 overhauls its experimental MVCC mode, which lifts SQLite's single-writer limit, adding index support, checkpointing and recovery. MVCC is now enabled with `PRAGMA journal_mode = 'experimental_mvcc'`, persisted in the file header, and makes the file unreadable by stock SQLite until you switch back to WAL. Partial sync fetches pages on demand, with bootstrap queries and prefetching (persistent mode is Linux-only because it needs sparse files), and sync now ships in the Python and Go SDKs. The release also adds page cache spilling for large queries, ANALYZE support for better join ordering, and a disk-spilling hash join for non-indexed columns in place of SQLite's ephemeral B-tree indexes.
- If I have read-only tables in Postgres, should I index them heavily?
Neon mediumAdept
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.