09 DynamoDB Best Practices
Автор: Cloudvala
Загружено: 2022-04-28
Просмотров: 190
Описание:
Table Best Practices
Understand some tips for table design.
We'll cover the following
Single-table design
Primary key design
Partition key design
Sort key design
Item Best Practices
Understand the art behind creating items.
We'll cover the following
Size limit
Attribute names
Compressed attributes
Dividing Items
Attaching to S3
Secondary Index Best Practices
Understand the tips and tricks to get the most out of GSIs.
We'll cover the following
Sparse index
Reversing sort key
Using as replica
Unless you want strongly-consistent reads and writes, it makes no sense to use LSIs. There are good reasons for avoiding LSI. The primary reason being the limit on the size of the item collection. You can’t have more than 10GB of data with the partition key. LSI also increases your partition size, which is not desirable.
Also, while using GSIs, we should be mindful of the projected attributes. If we project all the attributes, we waste write capacity. If we query for a non-projected attribute from GSI, we will consume extra read capacity. Hence, the rule of thumb is to project all the attributes that we query frequently.
Sparse index#
Only the items whose index keys are present are projected to the GSI. This means we do not consume write capacity on the items without an index key. A secondary index to which a few items are projected is called a sparse index. You should use sparse indexes as much as possible. The following figures show a sparse index.
Music Table
Only one item gets projected to the GSI
Reversing sort key#
It is a common practice to use the sort key of a table as the partition key for the GSI. This helps in aggregation queries and many-to-many relationships.
We can get all songs composed by composer#1 by querying GSI1 with Composer#1 as the partition key.
We can get the song that is downloaded the most in a month by querying GSI2 with month-08-21 as the partition key and downloads as the sort key. We should not forget to fetch in reverse order and limit our results to 1.
Using as replica#
GSI provides a very good way to create a replica for your table. This helps in the following cases:
When we don’t want to share all the attributes with some users, we can project the required attributes to GSI.
When we want to provide different read capacities to different users.
Keep in mind the GSI is eventually consistent. Hence, we should be able to tolerate some delays with our replication process.
~-~~-~~~-~~-~
Please watch: "01 05 Why Google Cloud Platform "
• Why Google Cloud Platform GCP
~-~~-~~~-~~-~
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: