Postgres relies heavily on statistics collected from data tables to execute queries in the most efficient way possible. Despite the relative simplicity of these statistics, the actual process by which they are collected and used to generate plans is very complex. In this talk, I will give a quick overview of the assumptions that the planner makes about data access patterns and the heuristics that generate and make use of the collected statistics. Then, I will show how custom selectivity functions can dramatically improve the planner accuracy for two very different, but common, data distributions.