Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

MySQL indexing - is it a tree?

 
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?
 
author & internet detective
Posts: 40200
816
Eclipse IDE VI Editor Java
  • 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!
 
You don't like waffles? Well, do you like this tiny ad?
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic