- The Primary Index is the column(s) that lays out the data row to the proper AMP.
- The Primary Index column(s) is also the fastest way to retrieve a row from that same AMP(this one we will discuss in next post).
- Teradata takes a table and spreads the rows across the AMPs one row at a time.
- A Unique Primary Index on the table will spread the data rows perfectly evenly across the AMPs.
- Teradata knows exactly which rows went to which AMPs so retrieval is always a 1-AMP operation when users use the Primary Index in the WHERE Clause of their SQL. Here is how that works.
Hashing the primary Index Value and Placing the row's.
- The Teradata Parsing Engine will take the Primary index value of a row and run a math calculation called the hash formula on that primary index column value.
- This hash formula does't change and can be calculated on any value or datatype.
- The result of hash formula will result in a number ranging from one to one million.
- The Teradata hashMAP with one million buckets, those buckets contain AMP number's. For example :- we have 4 AMP's in our TD system, so the million buckets contain numbers like 1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,........ million buckets. 1st bucket contain 1st amp number, 2nd bucket contain 2nd amp num, 3rd bucket contain 3rd amp num, 4th bucket contain 4th amp number, and 5th bucket contain 1st amp number, 6th bucket contain 2nd amp num.... like this upto million.
- 1st PE will generate row hash value of primary index value. that is 32 bit value, Is called Row Hash value.
- In that 32 bit value,1st 16 digits are find the Hash bucket value.(for example: think 1st 16 bit's of Row hash value is gave value like '20', so PE will go to that 20th number bucket, and that will take amp number)
- in that bucket we will get AMP number.
- based on this , the row will lays in AMP's.
- for example: We have one table in that table we have two columns number, name.. in this 'number' is primary index. now we are inserting one row in our table.
- INSERT INTO TABLENAME VALUES(101,'SANTHOSH').. in this primary index value is 101, so 101 value will go to hashmap for math calculations, and that will give 32 bit value of 101. in that 32 bit value 1st 16bit's will give one number for example take '34', so our bucket number is 34, in that bucket, we have amp value like '2'... now our row will goto that 2nd amp..
Thanks for visiting my Blog.. and if i missed any thing please let
me know.. or if you have any doubt's please give me
your valuable comment's.. i will give you proper answer..
Thanking you all..
Sorry yar..i d't know.. but i can help you, if you have any doubt let me know.. i will give my best..
ReplyDeleteand thanks for comment..