Database Reference
In-Depth Information
Default or primary indexes
Do you know that whenever you create a DynamoDB table, an index is also created? That
index is called as primary index. This primary index will include the primary key attributes
(both hash and range keys). The index created over a hash key is an unordered hash index.
What it means is that the items with the same hash key will be grouped together and placed
adjacent to each other, which helps in faster retrieval of items with the same hash key at-
tributes (using the scan operation), but there will not be any ordering in the item on the
hash key attribute.
Just for illustration purposes, let's go back to the Tbl_Book table:
Here, you can see that the items with the same BookTitle attribute (which is the hash
key attribute) are placed adjacent to each other, because as soon as the table is created, this
index will be created, and whenever an insertion takes place it will hash this attribute using
some hash logic and place it in the correct location. If you look at the ASCII code or the
English alphabetical order, L as in Let us C comes before S as in SCJP . Since the index cre-
ated on the hash key is unordered, the items will not be sorted on this attribute.
Another noticeable concept is the index created on the Author#Edition attribute
(which is the range key attribute); it works deeper on the tree created by the hash key in-
dex. This index will order the items that have the same hash key (but of course with differ-
ent range key values) either in descending or ascending order. To put it in RDBMS terms,
Search WWH ::




Custom Search