4 messages in com.mysql.lists.clusterRe: NDB indexes; structure and usage| From | Sent On | Attachments |
|---|---|---|
| Jigal van Hemert | 23 Jun 2005 01:01 | |
| Mikael Ronström | 23 Jun 2005 02:04 | |
| Mikael Ronström | 23 Jun 2005 02:05 | |
| pek...@mysql.com | 23 Jun 2005 02:35 |
| Subject: | Re: NDB indexes; structure and usage![]() |
|---|---|
| From: | pek...@mysql.com (pek...@mysql.com) |
| Date: | 06/23/2005 02:35:55 AM |
| List: | com.mysql.lists.cluster |
Hi
Can anyone explain a bit about the way NDB indexes are structured, where they live, when and how indexes are used in queries, etc.?
First keep in mind data is distributed on several nodes based on hash of primary key. There's 4 types of access methods, the first 3 are index based:
1) primary key: on each node uses "linear hashing" (google)
2) unique hash index is implemented as table:
t (a, b, primary key (a), unique key x (b)) => x (b, a, primary key (b))
The index table x has different pk so it is distributed differently than t. Every index operation must go through the transaction coordinator (TC). To find table tuple requires 2 key lookups: x(b) and t(a).
3) ordered index is a "T-tree" (google)
These are just additional data structures tied to data storage (TUP) on each node. They are very compact since only local address of tuple is stored.
4) finally full table scan returns all tuples from table
1) and 2) can only do single tuple operations for given key. 3) can only do scans between 2 key values.
3) and 4) scan all nodes is parallel. For all access types additional batching is done when possible.
Index usage is decided by MySQL optimizer. Before 5.1 there are no good index statistics so non-optimal index may get used.
Hope this helps.
-- Pekka Nousiainen, Software Engineer MySQL AB, www.mysql.com pek...@mysql.X.com +46 (0) 73 068 4978




