Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQL indexing - is it a tree?

 
Ivan Jouikov
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a table,



which will store account stuff, such as address email, name, phone, and whatever the hell I come up with.

So you get the idea, the table will be huge. For every account there will be like 10 different rows.

So, I was wandering, is it the best way to do INDEX(accID), INDEX(name), will that give you a tree structure? Because efficiency here will be the key. I forsee my statements to retrieve an attribute to be something like

SELECT value FROM account_attributes WHERE accID='?' AND name='?'

... Is this how you would do it? Or is there a more efficient way?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ivan,
Creating just the index on accID is enough. The database will get the 10 or so rows and then look through only those for the given name. This happens very quickly.

While, you could do an index of accID and name, it would be roughly 2/3 as large as the full table. So it wouldn't be as fast.

Having 2 separate indexes for accID and name doesn't help you because the database can only use one at a time.
 
Ivan Jouikov
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic