Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have this following sentence:

SELECT Day(C.DataCadastro) AS Dia, 
       Month(C.DataCadastro) AS Mes, 
       Year(C.DataCadastro) AS Ano, 
       COUNT(I.Plano) AS Total 
FROM clientes AS C 
   JOIN clube_infoclientes AS I ON C.CodUsuario = I.ClienteID 
WHERE ((I.Plano = 1) AND (C.Ativo = 1)) 
GROUP BY Mes 
ORDER BY Dia, Mes, Ano

The name of index is: Plan. sentence of creating is
CREATE INDEX Plan ON clube_infoclientes (Plano(2));

But I can't use INDEX here.. My question is how I do implement INDEX on the select above

share|improve this question

closed as unclear what you're asking by billinkc, Max Vernon, RolandoMySQLDBA, Mark Storey-Smith, ypercube Nov 6 '13 at 19:14

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

    
What is your question? –  a_horse_with_no_name Nov 5 '13 at 18:27
    
Oh sorry. My question is how I do implement INDEX on the select above? –  Bruno Casali Nov 5 '13 at 18:32
    
What do you mean with "implement index"? That doesn't make sense. Indexes are created (using a create index like the one you have) - they are not "implemented". –  a_horse_with_no_name Nov 5 '13 at 18:35
1  
You don't "use" indexes. The optimizer chooses them automatically if it makes sense. And they don't change the result of a query, they improve the speed, that's all. –  a_horse_with_no_name Nov 5 '13 at 18:45
1  
@BrunoCasali Consider to edit your question and include some sample data and the desired output from the query based on that sample data. That can clarify your question and help you get your answer. –  peterm Nov 6 '13 at 13:49

1 Answer 1

up vote 0 down vote accepted

my problem's it:

I was using the indexes with two columns that are not important to me! I Resolve using indexes on the following columns: C.CodUsuario = I.ClienteID

Thanks to all! ;D

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.