Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB : List all partition keys

I want to update contains in DynamoDB, for which I need to iterate over existing partition keys present in table. Is there any way to fetch only list of partition keys using Python. Scan and Query only work on attributes of my table. Is there any way to get all partition key for table ?

like image 985
WPrathamesh Avatar asked Feb 08 '18 15:02

WPrathamesh


People also ask

Can DynamoDB table have multiple partition keys?

Short description. There are two types of primary keys in DynamoDB: Partition key: This is a simple primary key. If the table has only a partition key, then no two items can have the same partition key value.

How many partition key can DynamoDB have?

Each partition is roughly 10GB in size, so DynamoDB will add additional partitions to your table as it grows. A small table may only have 2-3 partitions, while a large table could have thousands of partitions.

Is partition key same as primary key in DynamoDB?

The primary key uniquely identifies each item in the table, so that no two items can have the same key. DynamoDB supports two different kinds of primary keys: Partition key – A simple primary key, composed of one attribute known as the partition key.

How many partitions are there in DynamoDB table?

Therefore, to accommodate the request, DynamoDB will automatically create 10 partitions.


1 Answers

If your table uses sort keys in addition to the partition keys (stated differently, if the keys are composite of partition + sort key) then the answer is: no - there is no way to query or scan for just the partition keys. To clarify, you can still scan your table with a projection that returns the keys only, but it will return each primary key multiple times, once for each item that has the same primary key with a different sort key.

If your table schema uses partition keys only (no sort key) then you can write a scan with a projection of only the primary key and therefore, get the list of partition keys as a result.

like image 138
Mike Dinescu Avatar answered Sep 17 '22 13:09

Mike Dinescu