The query is basically:
SELECT DISTINCT \"my_table\".\"foo\" from \"my_table\" WHERE...
Pretending that I\'m 100% certain the DISTINC
DISTINC
Oftentimes, you can make such queries run faster by working around the distinct by using a group by instead:
distinct
group by
select my_table.foo from my_table where [whatever where conditions you want] group by foo;