Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have table with 14 column, and search can be done in any fields separately or mix, so i wanted to index all columns is that a good idea to have 14 indexes?
and my other question is because i wanna search more than 1 column in same time in some cases is it good to have multi_column index?
i can't really predicte wich columns are most used for search because it's an analytical project
Posted

1 solution

It depends:
Fewer indexes = faster insert / update, slower query
More indexes = slower insert / update, faster query

You have to weigh it up against the common usage.

One way to reduce search time is to have a term table (pretty much every single word used) and a link table to the rows that contains those words.

As you can imagine, the search is sped up, but inserting all those link rows takes time.

This is essentially what adding indexing does.

I hope that helps. It's a very poor analogy really, and it's probably poorly put too.

Let me know either way ^_^
Andy
 
Share this answer
 
Comments
Saeed.A 26-Aug-15 7:46am    
thanks actualy i know but i was wondering if i dont know something so what about mix column search do i have to have multi_column index?
Andy Lanng 26-Aug-15 7:58am    
hmm - again depends on how you use it. If you have a fullname search and only a forename and surname field, then I would create a calculated field with an index, but this is where TSql and MySql diverge. I am a pro in the former but I've not really ever used that later :/
Saeed.A 26-Aug-15 12:25pm    
by the way thanks a lot, can u help me to make a trigger to validate my data in any field in my table?
Andy Lanng 26-Aug-15 12:30pm    
Dear god no! Not that I won't help you, but for the love of Pete don't validate data with triggers o_O
Saeed.A 26-Aug-15 20:55pm    
so can u give a solution on this?
http://www.codeproject.com/Questions/1022366/Mysql-Trigger-validating-data
i just wanna keep it on mysql level not application level because it may change a lot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900