What is a DynamoDB LSI (Local Secondary Index) ?

  Рет қаралды 66,350

Be A Better Dev

Be A Better Dev

Күн бұрын

Пікірлер: 100
@spider279
@spider279 2 жыл бұрын
You are the hero who saves me for my presentation of dynamoDB at class , such a great explaination
@pravinbudage3942
@pravinbudage3942 2 жыл бұрын
You have explained it very smoothly and cleared all the doubts. Thanks
@BeABetterDev
@BeABetterDev 2 жыл бұрын
You're very welcome!
@yogiHalim
@yogiHalim 4 жыл бұрын
great vid. Thanks. First example on 4:00 mins, first approach scan on entire table, should read all data including forum name EC2 and RDS. You stopped at S3 while not entirely wrong but mildly confusing at first as compared to second approach.
@yogiHalim
@yogiHalim 4 жыл бұрын
Thanks for the code snippets 7:05 mins (just leaving a shortcut here)
@roboprofit2548
@roboprofit2548 3 жыл бұрын
Great video. Keep in mind that more LSI more cost. AWS DOC ==> "A table with many local secondary indexes incurs higher costs for write activity than tables with fewer indexes" However, writing to the base table with 2 LSIs still cost 1 WCU IF you don't write to LSIs as well. If you write to 1 LSI then it costs 2 WCUs ( 1 for the table and 1 for LSI)
@BeABetterDev
@BeABetterDev 3 жыл бұрын
Great point! Thanks for sharing.
@bradw2k
@bradw2k 3 жыл бұрын
When would a write to a table not result in a write also to its GSI?
@tahiraziz193
@tahiraziz193 2 жыл бұрын
Hi @Robo Profit would be great if you can share any reference please? i have gone through the AWS documentation but couldn't find this. Thanks
@roboprofit2548
@roboprofit2548 2 жыл бұрын
@@bradw2k when you don't write to the index and only write to the base table
@SpotCallerzWrestling
@SpotCallerzWrestling 4 жыл бұрын
This is exactly what I needed! Thanks very much. Saved me a lot of money.
@BeABetterDev
@BeABetterDev 4 жыл бұрын
You are very welcome!
@mugssyy
@mugssyy 2 жыл бұрын
Hi ! Your videos are great! I had trouble understanding the LSI and GSI for a long time. Thank you . going through more of your content.
@BeABetterDev
@BeABetterDev 2 жыл бұрын
Thanks so much Mugdha!
@prvinsharma
@prvinsharma 2 жыл бұрын
Well explained! I was going through PluralSight and got lost there with LSI and GSI. Had to hop in here as the first and greatfully the last for LSI. GSI would be next. Thanks
@Sami-ec9sd
@Sami-ec9sd 4 ай бұрын
There is one limitation when using LSI: Your Data being stored within the same partition key isn't anymore allowed to exceed 10GB. If you have reached 10GB you wont be able to add more items (you get the error ItemCollectionSizeLimitExceededException). You can read about this in the aws doc with the title "Local Secondary Indexes" and the subtitle "Item collections in Local Secondary Indexes"
@aamersohail474
@aamersohail474 3 жыл бұрын
Thank you so much for exemplifying it so clearly.
@BeABetterDev
@BeABetterDev 3 жыл бұрын
You're very welcome Aamer!
@krishnasmusicchart4897
@krishnasmusicchart4897 2 жыл бұрын
Explained excellently, sir
@BeABetterDev
@BeABetterDev 2 жыл бұрын
Thank you
@gdemelo
@gdemelo 9 ай бұрын
Great explanation. I would recommend providing SDK examples with Javascript/NodeJS or Python, instead of Java, though.
@windowcrystal4012
@windowcrystal4012 4 жыл бұрын
Speed: Scan then filter < query on partition key < LSI
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Spot on!
@TomerBenDavid
@TomerBenDavid 4 жыл бұрын
Very clear! Last limitations section was great. I would also suggest to add what are the drawbacks when should you not use it obviously it does not come for free and you might want to use a different db like a mirror in some other place to do these queries based on your intent there is a reason it's a simple kv. Great video many thanks.
@mqtt07
@mqtt07 Жыл бұрын
One other limitation, just to be clear, is that you can change the sort key, not the partition key in an LSI
@JesusAlfredoHernandezOrozco
@JesusAlfredoHernandezOrozco Жыл бұрын
Great video! Really well explained. I recommend it!
@worddoc4322
@worddoc4322 3 жыл бұрын
Thank you for the video. I have a question: once a sort key has been set, a table keeps its data sorted by that key. LSI is considered as an extension of the sort key. How the table gets sorted by a pack of sort key + multiple LSI? I think there is something different behind LSI. Could you shed light on it please?
@niteshgupta8436
@niteshgupta8436 2 жыл бұрын
I also have the same doubt. Please explain.
@karahisarli
@karahisarli 4 жыл бұрын
Great videos and explanation, appreciate the effort, tried couple of blogs/documents but very clearly stated here. Can you please give some tutorials on schema design specially some relations?
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Thanks serdar. I'll look into incorporating relations in an upcoming video!
@sameeshoncloud9
@sameeshoncloud9 4 жыл бұрын
amazing work buddy
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Thank you! Cheers!
@jwalaivaturi
@jwalaivaturi 3 жыл бұрын
Thanks for the awesome video. Queries or scans on a local secondary index consume read capacity units from the base table and updates consume write capacity units from the base table. What do you mean by no extra cost with LSI?
@Xhez2slash
@Xhez2slash 3 жыл бұрын
It is compared to the GSI, where if you create an another GSI for your table that would incur extra cost. (provision extra wcu/rcu for the table created)
@_arshadm
@_arshadm 2 жыл бұрын
You left one of the most important questions unanswered. Does the LSI range key attribute also need to be unique in combination with the hash key (i.e. LSI is just another sort key)
@renatolimasantos8618
@renatolimasantos8618 2 жыл бұрын
From aws docs: "In a DynamoDB table, the combined partition key value and sort key value for each item must be unique. However, in a local secondary index, the sort key value does not need to be unique for a given partition key value. If there are multiple items in the local secondary index that have the same sort key value, a Query operation returns all of the items that have the same partition key value. In the response, the matching items are not returned in any particular order."
@_arshadm
@_arshadm 2 жыл бұрын
@@renatolimasantos8618 Thanks, I was looking for this additional info. This makes the LSI a lot more useful.
@Viet100
@Viet100 3 жыл бұрын
I have a question for scan operation. if I scan by PK and Subject="aaa" for example, does dynamodb scan/read "LastPostDateTime"? or it just scan the specified column (not all columns).
@BeABetterDev
@BeABetterDev 3 жыл бұрын
Hi Clouder, Scans will return the entire row, so all the columns. Hope this helps.
@Viet100
@Viet100 3 жыл бұрын
@@BeABetterDev thanks for your effort. keep it up.
@zacsonskaria
@zacsonskaria 4 жыл бұрын
The PartitionKey + SortKey may not be unique, since two subjects in a forum can have same LastPostDateTime. It may not be relevant since it is just an example and the focus is something else, however it can cause confusion in my opinion.
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Hi Zacson, thanks for pointing this out. You are absolutely correct.
@pikachu5223
@pikachu5223 2 жыл бұрын
There you can use the suffix pattern
@rongrongmiao3018
@rongrongmiao3018 Жыл бұрын
If you use Unix epoch time it would be unique
@zacsonskaria
@zacsonskaria Жыл бұрын
@@rongrongmiao3018 Why do you think that the unix epoch time won’t collide when generated at the same time?
@xamry_
@xamry_ 4 жыл бұрын
Thanks, to the point and easy to understand.
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Glad it was helpful!
@ankitgarg568
@ankitgarg568 4 жыл бұрын
Great video. Helped me a lot!!
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Glad it helped!
@jeffinj7707
@jeffinj7707 3 жыл бұрын
Very helpful. A quick question: I have a large JSON data, how can I create a table with that JSON structure. And can we populate the table with a JSON file?
@MohammadFaizanAli786
@MohammadFaizanAli786 4 жыл бұрын
It's a great video but could you explain how Amazon does it internally? How does it not create more tables and still gives such fast results? If we have local index can we choose to not provide it?
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Hey Mohammad, Unfortunately there isn't much documentation in terms of how aws structures LSIs so really its anyone's guess.
@hejiaji
@hejiaji 2 жыл бұрын
In this example, how can the primary key be assured to be unique? ForumName(Partition key) + LastPostDateTime(SortKey) could definitely be duplicated right?
@sunwoojeong9996
@sunwoojeong9996 2 жыл бұрын
Thank you for your lecture. Is LSI sth like a sort key, without having the uniqueness limitation of (partition key, sort key) pair?
@BeABetterDev
@BeABetterDev 2 жыл бұрын
Hi Sunwoo, that's a good way of thinking about it!
@sunwoojeong9996
@sunwoojeong9996 2 жыл бұрын
@@BeABetterDev Got it. Also, for GSI, the whole table (data) is physically replicated to multiple machines. Is LSI also copying some portion of data (the data corresponding to the right partition key) and storing them in different orders?
@juancpgo
@juancpgo 4 жыл бұрын
Great content. 👍 Thank you.
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Thanks Juan! Glad you enjoyed.
@abhishekpaithane6292
@abhishekpaithane6292 2 жыл бұрын
great explanation!
@ahmedal-shamari414
@ahmedal-shamari414 4 жыл бұрын
thanks for your awesome Video can I ask about the brief difference between GSI and LSI? from the 2 videos I think the difference that LSI must be defined at table creation time, no Extra Cost, max 5 LSI per table, it is alternative to range key while GSI can be defined any time, need extra cost, no limitation per table, also GSI= new Partition key + new sort key am I correct with the above? thanks and best regards
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Hi yes you are correct. Also keep in mind the purpose of the LSI and GSI are fundamentally different. LSI helps you define more range-like queries on a different index. Whereas GSI allows you to perform direct key lookups on the corresponding index.
@josecruz2574
@josecruz2574 4 жыл бұрын
@@BeABetterDev so if looking for a specific index - GSI would be more appropriate?
@eric19435
@eric19435 4 жыл бұрын
Nice video. What is the use case of GSI and LSI? What is the different between them?
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Hi Eric, GSIs allow you to query for specific attributes other than the partition key. LSIs allow you to perform 'range-like' queries on your LSI's range key.
@josereneherrerauribe-ceiba8047
@josereneherrerauribe-ceiba8047 4 жыл бұрын
Hello, excellent video! You have any java repository with examples?
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Hi Jose, I unfortunately dont but will look into setting one up. Thanks for watching.
@arhabersham
@arhabersham 3 жыл бұрын
Well explained ❤️
@BeABetterDev
@BeABetterDev 3 жыл бұрын
Thanks Alfredo! Glad you enjoyed :)
@ravisaraswat6519
@ravisaraswat6519 4 жыл бұрын
You are great , keep up the excellent wok.
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Thank you kindly
@ognjenaskovic1830
@ognjenaskovic1830 2 жыл бұрын
Hey, total newbie to Dynamo here. I have a question regarding combination of GSI and LSI. So, if my table has one GSI and one LSI defined, can I do the query which uses GSI as a hash key value and LSI as a range key value ? That would make my life a lot easier, but I'm not sure if it is possible. Will appreciate any help :)
@sardesaisantosh
@sardesaisantosh Жыл бұрын
how can an entire table scan will happen when you have a partition key on forumname in the example for fetching records with s3 and subject = aaa
@jeevanthomaskoshy8979
@jeevanthomaskoshy8979 3 жыл бұрын
Won't LSI also duplicate the data like the global secondary index? So wouldn't that lead to increased cost ?
@sauer.voussoir
@sauer.voussoir 3 жыл бұрын
same question, if does also create a new table copy like GSI
@alekseiborsenkodev
@alekseiborsenkodev 2 жыл бұрын
Nice explanation, but I have a little correction. You CAN NOT search by endsWith. only beginwith
@angry740
@angry740 4 жыл бұрын
Excellent!!
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Thank you! Cheers!
@zeretil
@zeretil Жыл бұрын
This is confusing to me as a rookie -- isn't your partitionkey supposed to be unique? Even when using the Sort Key as part of your partition key, there can be duplicates when two forum posts are updated at the same time?
@vagifk2864
@vagifk2864 4 жыл бұрын
Should LSI be unique within the same table?
@BeABetterDev
@BeABetterDev 4 жыл бұрын
It does not necessarily have to be.
@sonny23ization
@sonny23ization 3 жыл бұрын
why is this strongly consistent?
@rickfarina9835
@rickfarina9835 4 жыл бұрын
What is the criteria to use an LSI vs. a GSI? Or, is there now no benefit to using LSIs?
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Hi Rick, LSIs can unfortuantely only be defined when the table is created and solve a bit of a different purpose than LSIs. LSIs allow you to perform 'range-like' queries on a data field provided you know the partition key. GSIs allow you to perform direct lookups or queries on fields other than the partition key. Hoep this helps!
@rickfarina9835
@rickfarina9835 4 жыл бұрын
@@BeABetterDev Hi... First, thank you for this series of AWS videos. Absolutely fantastic!! On the LSI/GSI difference, it caused me to re-read the docs and do some testing. I still have the understanding that a GSI can be built over the same Partition Key (PK); and can use either the same or different Sort key (SK) than the base table, which I believe implies a range. For example: "Select PK='x' and SK between 10 and 15". I believe this represents a "Range-Query" that you mentioned above. If this is true, doesn't that mean the GSI has essentially the same Query capabilities as the LSI? If so, I'm sill not sure what benefit the LSI has over the GSI, other than it's stored along with the base table rather than creating its own Partitions as the GSI does. Thanks again, so much. Rick
@__noob__coder__
@__noob__coder__ Жыл бұрын
Which coding font are you using ?
@BeABetterDev
@BeABetterDev Жыл бұрын
Liberation Mono
@mhlaskar1991
@mhlaskar1991 4 жыл бұрын
Does LSI doubles the space like GSIs?
@BeABetterDev
@BeABetterDev 4 жыл бұрын
Hi Mahbubul, LSIs do not take extra space. Thanks for watching!
@The6thProgrammer
@The6thProgrammer 3 жыл бұрын
@@BeABetterDev I don't believe this answer is correct. I believe similar to GSIs the LSIs will consume more space and consume WCUs as well. See here docs.aws.amazon.com/amazondynamodb/latest/developerguide/LSI.html where it is mentioned in the AWS documentation "The smaller the index, the less that it costs to store it, and the less your write costs are". This is why there is a trade-off in how many additional attributes you would want to project in your LSI.
@warrenjohnson5971
@warrenjohnson5971 3 жыл бұрын
@@The6thProgrammer No more read units but more space consumed I guess?
@ralfrolfen5504
@ralfrolfen5504 7 ай бұрын
perfect!
@LifeDude
@LifeDude 3 ай бұрын
Awesome
@leiliu83
@leiliu83 4 жыл бұрын
So for LSI, hash key + range key does not need to be the same
@SurprisedFirzen
@SurprisedFirzen 3 жыл бұрын
partition key needs to be the same right
@adamkinsey3139
@adamkinsey3139 2 жыл бұрын
So...let's design and sell a "NoSQL" database, and then add in "fancy" features so that users can pay extra to have a fraction of the SQL features? I genuinely don't understand why you would choose to use a "NoSQL" database for any use-case like this....and I would love to know!
@BeABetterDev
@BeABetterDev 2 жыл бұрын
Hi Adam, Thank you for the comment. I have a video on RDS vs DynamoDB that attempts to answer your question. You can watch it here: kzbin.info/www/bejne/maOrqJihm5WaiqM Hope this helps, Daniel
@harshjain8823
@harshjain8823 Жыл бұрын
take some break when you finish a sentence.
@waytospergtherebro
@waytospergtherebro Жыл бұрын
This is the single most useless "database" anyone has ever designed.
What is a DynamoDB GSI and How to Create One?
8:03
Be A Better Dev
Рет қаралды 13 М.
AWS DynamoDB Schema Design | How to choose the right key
12:15
Be A Better Dev
Рет қаралды 213 М.
Ozoda - Lada ( Official Music Video 2024 )
06:07
Ozoda
Рет қаралды 30 МЛН
Бенчик, пора купаться! 🛁 #бенчик #арти #симбочка
00:34
Симбочка Пимпочка
Рет қаралды 3,1 МЛН
Миллионер | 1 - серия
34:31
Million Show
Рет қаралды 2,9 МЛН
ДЕНЬ УЧИТЕЛЯ В ШКОЛЕ
01:00
SIDELNIKOVVV
Рет қаралды 4 МЛН
What is a DynamoDB GSI (Global Secondary Index) ?
10:19
Be A Better Dev
Рет қаралды 120 М.
What is a DynamoDB Stream? (And why you should be using it!)
14:59
Be A Better Dev
Рет қаралды 65 М.
What is DATABASE SHARDING?
8:56
Gaurav Sen
Рет қаралды 933 М.
The only Cloud services you actually need to know
17:17
NeetCodeIO
Рет қаралды 170 М.
AWS DynamoDB Tutorial For Beginners
38:12
Be A Better Dev
Рет қаралды 363 М.
Single-Table Design with DynamoDB - Alex DeBrie, AWS Data Hero
1:09:32
AWS Portsmouth User Group
Рет қаралды 66 М.
DynamoDB in 20 Minutes - Intro to NoSQL
20:16
Caleb Curry
Рет қаралды 9 М.
Microservices are Technical Debt
31:59
NeetCodeIO
Рет қаралды 519 М.
Ozoda - Lada ( Official Music Video 2024 )
06:07
Ozoda
Рет қаралды 30 МЛН