Which query is faster?
SELECT DISTINCT Category FROM Clients
SELECT Category FROM Clients GROUP BY Category
My hunch is that #1 runs faster especially with an index, any comments on this?
TAB (Thanks a bunch), Sam Fullman
i think so too, but if you suppose categories to appear more than once qhy do you not have a table called category and in your table client you only have a foreign key to this table?
than you could simply query the table "category" which sould be much faster
the client creates the table, not I, but my system creates the form elements for them..
Sam
well, if you really can't change the database layout you are stuck to DISTINCT
GROUP BY will be slower because it does in easy words the very same that DISTINCT does but does some more stuff you don't need
Care to expand on what that more stuff is?
As the queries are equivivalent they should result in the same query plan.