Something faster than SELECT DISTINCT item FROM DB?

advertisements

Is there any alternative to

SELECT DISTINCT item FROM DB

I have already tried:

SELECT item FROM DB group by item

the table isn't so large (30,000 rows) but this command takes almost 6 seconds to complete. On the other hand, other queries perform very fast (0.2 seconds).

What might be going on? Suggestions?

By the way, this is how I am using it in my program:

BDD.addItems([r[0] for r in cursor.execute("SELECT DISTINCT commodity FROM DB")])


make sure there is an index on the distinct column