From: Jorge Bastos Date: November 6 2009 9:33am Subject: RE: Help on query performance List-Archive: http://lists.mysql.com/win32/19048 Message-Id: <004101ca5ec4$2f3e8d70$8dbba850$@jorge@decimal.pt> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Howdy Jesper, > Sorry - looked a bit further into you table syntax > > Since both emp and ano are primary keys already - only set non-unique > composite index on (arm_cod, cod_art) > > Maybe you could enlighten me by explaing why using many primary indexes > instead of on primary and several unique composite indexes > Yap, after i sent the email i saw that i was missing the index's. I always fall on that error :P > > Setting non-unique composite index on (emp, ano, arm_cod, cod_art) > should make the query real fast. Indexes are most important for finding > what rows to look in. Ie in this case - the parameters within WHERE. > Indexing columns that are not used in WHERE syntaxes or in JOIN > syntaxes are rarely useful, only space consuming. Indexeing also > somewhat slows down UPDATEs and INSERTs. Normally not a hazzle unless a > lot of fields are often updated and inserted. > > You ought to be fine with only non-unique composite index on (emp, ano, > arm_cod, cod_art) > > /Jesper