Original link: Our PostgreSQL Query Took 47 Seconds. I Fixed It in 3 Lines of Code. / Devrim Ozcay blog.
Both problem and solution are trivial. But it still happens every day!