A query that results in a large number of rows may put you in lossy mode.
Every database connection has allocated space. The amount is set by
WORK_MEM in your postgres settings. If the bitmap cannot reference each tuple in the relation within the allocation then the database planner will enter
You can determine if you are in
lossy_mode by checking the query plan.
Here are a few common approaches to reduce the bitmap heap scan size. Typically, I would recommend them in the order listed:
- Improve your query
- Paginate you results
- Optimize your indexes
- Add a partial index
- Increase the
Example from the query plan:
EXPLAIN ANALYZE SELECT * FROM large_table => .... Heap Blocks: exact=2000 lossy=50000 ...
Did you like this article? Check out these too.
Found this useful? Know how it can be improved? Get in touch and share your thoughts at