If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Using Btree

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-30-07, 08:39
krReddy krReddy is offline
Registered User
 
Join Date: Oct 2006
Posts: 83
Thumbs down Using Btree

CREATE TABLE temp (
tempvar1 varchar(12) NOT NULL default ''
,
KEY Firstkey USING BTREE(tempvar1)
)


Please tell me what is the use of using the key word 'USING BTREE',
Will it make any difference in the result
Reply With Quote
  #2 (permalink)  
Old 04-30-07, 09:02
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
By doing "USING BTREE(tempvar1)" you are telling MySQL that the index for that key should be created using the Binary Tree algorithm. If you leave USING BTREE off your statement it will default to use whatever algorithm is set as default on your server (usually BTREE).

MySQL maintains three algorithm types (as far as I am aware). They are BTREE, HASH, RTREE. Each has their own implementation of how to find/insert/delete values for indexes. Defining which you are using for a key is entirely dependent on what you're expecting to be done to that table that maintains the key.
Reply With Quote
  #3 (permalink)  
Old 05-04-07, 00:02
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Baghdad, Iraq
Posts: 697
Quote:
Originally Posted by aschk
By doing "USING BTREE(tempvar1)" you are telling MySQL that the index for that key should be created using the Binary Tree algorithm.
If you're dead set on trying to improving performance by overriding the years of experience of the MySQL development team, you should at least know what the words mean.

A binary tree is a data structure, not an algorithm. Further, the structure MySQL uses is a variant of the b-tree, not a binary tree.

It shouldn't make any difference in the result. However, it would be prudent to perform regression testing. That is, set up two identical databases, one with and one without the indexes. See if a set of test queries on test data produces bit for bit identical results.
Reply With Quote
  #4 (permalink)  
Old 11-08-07, 11:57
kinzze kinzze is offline
Registered User
 
Join Date: Nov 2007
Posts: 3
*-Tree

What if i wanted to test another tree? is it possible to do it?

thanks in advance,

Jorge
Reply With Quote
  #5 (permalink)  
Old 11-09-07, 07:30
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
Yes just change the tree type in the SQL create statement.

USING HASH(tempvar1)
USING RTREE(tempvar1)
USING BTREE(tempvar1)

I'm not sure if MySQL has plans for other data structure in the future, or you can "compile" an alternative into it, but the ones i've listed here are the available ones as of 5.0.27-community version.
Reply With Quote
  #6 (permalink)  
Old 11-09-07, 12:01
kinzze kinzze is offline
Registered User
 
Join Date: Nov 2007
Posts: 3
Quote:
Originally Posted by aschk

I'm not sure if MySQL has plans for other data structure in the future, or you can "compile" an alternative into it, but the ones i've listed here are the available ones as of 5.0.27-community version.
That is exactly what i am looking for. I want to try an alternative but i don't have a clue about how to do it.. do you know some site that has some relevant info?

thanks,

Jorge
Reply With Quote
  #7 (permalink)  
Old 11-12-07, 10:33
aschk aschk is offline
Registered User
 
Join Date: Mar 2007
Location: 636f6d7075746572
Posts: 770
wikipedia, google, mysql.net
All of the above will assist you in learning how these structures are formed.

Are you trying to create your own? I would advise against that (unless your MIT or Harvard material), and just use proven structures. The ones I listed are available to MySQL. In reality for the "user", just use the default.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On