2009/7/29 Dan Armbrust <[email protected]>: >> Problem 1: >> >> select id_group, count(id) >> group by id_group >> >> This takes a couple of minutes, > > Is that the entire query? No where clause? > > I don't think any database is going to use the index when you aren't > providing a where clause... especially when you have a count and a > group by in there... it has to read the entire table.
Well, initially, I would have agreed with you, but after having thought about it for a while and having read a couple of threads in various forums and mailing lists, I think it's not impossible: an index might in fact be useful if all the information is inside it, i.e. the table itself doesn't need to be read. Still, you might be right: I'm not sure yet.
