How to Create Local Secondary Index in DynamoDB | LSI in DynamoDb

Watch my YouTube video for explanation :



Please look into the class notes here for your references:

Local Secondary Index: -

FormPost   Table



Partition Key= ForumName

Sort Key (Range Key) = LastPostDateTime

 

{

    TableName: " FormPost",

    KeyConditionExpression: " ForumName= :a and LastPostDateTime=:t",

    ExpressionAttributeValues: {

        ":a": "EC2",

        ":t": "2015-02-12:11:07:56"

    }

}

Only one sort key is applicable for a DynamoDB table so applying expression condition becomes difficult.

Approach 1 – Scan it Read Capacity costs money – costly and poor latency

Approach 2 -  FormName==’S3’   narrow down the data

                       Subject ==’aaa’  - looks poor latency and also costly

Approach 3. Create LSI on Subject

 

{

    TableName: “ FormPost”,

    KeyConditionExpression: “ ForumName= :a and Subject =:t”,

    ExpressionAttributeValues: {

        “:a”: “EC2”,

        “:t”: “aaa”

    }

}

 

       

 

Partition key remain same but the sort key becomes ‘Subject’

 

Limits:

a.      LSI can be defined at table creation time

b.      5 LSI (Soft Limit) currently but can be checked with AWS support to increase the limit.

c.      No Extra cost*** 


Fore more Abinitio, AWS and data engineering videos please subscribe , view , like and share my YouTube channel 

Click DataPundit


Comments

Popular posts from this blog

Abinitio Interview Question # 1 - Write Multiple Files in Abinitio

Next In Sequence in ABinitio | How next_in_sequence() works in MFS