Solution for speeding up a slow SELECT DISTINCT query in Postgres
Oftentimes, you can make such queries run faster by working around the distinct by using a group by instead: select my_table.foo from my_table where [whatever where conditions you want] group by foo;