1
00:00:00,150 --> 00:00:04,740
In this video, we will perform query operation in the same order table.

2
00:00:04,800 --> 00:00:11,840
You can see in here if you click the reset now this time I'm going to use Query Operation for that purpose.

3
00:00:11,850 --> 00:00:13,800
Click this query section.

4
00:00:13,800 --> 00:00:20,430
And as you can see that this time we will see both primary key and the sort key.

5
00:00:20,430 --> 00:00:27,340
So query operation is expecting and requiring us both primary k partition key and circuit.

6
00:00:27,360 --> 00:00:31,080
That means it is expecting to us the whole primary key.

7
00:00:31,260 --> 00:00:34,910
So in order to do that, I'm going to add the ID one.

8
00:00:34,920 --> 00:00:41,280
We can see that when we reset this one and click the run button, we have it two items.

9
00:00:41,280 --> 00:00:46,740
And if you click to query and give the partition key ID we need to give also sort key.

10
00:00:46,740 --> 00:00:50,250
So in the sort key, for example, I would like to give delivery.

11
00:00:50,250 --> 00:00:58,890
So if we can run this command, it is to turn us to the first item in the dynamic DB and we can perform

12
00:00:58,900 --> 00:01:00,510
quail patient successfully.

13
00:01:00,720 --> 00:01:06,090
As you can see that we have performed qualification both providing the partition and the third key.

14
00:01:06,120 --> 00:01:12,930
Also, we can add additional filter expressions in here like the scan operation, but this is the best

15
00:01:12,930 --> 00:01:19,770
practice if we have a sort key and would like to seek our table with the sort K, we should run the

16
00:01:19,770 --> 00:01:20,970
query operations.

17
00:01:20,970 --> 00:01:26,970
Scan operations are always costly and we should avoid to run second operations from our applications

18
00:01:26,970 --> 00:01:29,070
using the sort key index dynamo.

19
00:01:29,080 --> 00:01:33,990
DB Exactly knows where this records is using indexes in its database.

20
00:01:34,380 --> 00:01:40,620
It is using the consistent hashing storage run so it can quickly find out where data is and retrieve

21
00:01:40,620 --> 00:01:41,880
data very fast.

22
00:01:41,880 --> 00:01:48,150
So there is no lookup operation when querying with the keys on dynamic DB and this is the best practice

23
00:01:48,150 --> 00:01:55,080
to use to create a command with the sort key when querying your tables so we can also perform the filter

24
00:01:55,080 --> 00:01:55,680
expressions.

25
00:01:55,680 --> 00:02:00,120
If you expand this window, you can give, for example, total price.

26
00:02:02,180 --> 00:02:05,090
Is equal to 5000.

27
00:02:05,360 --> 00:02:08,870
And if you run query, you can see the exact same response.

28
00:02:08,870 --> 00:02:13,730
If you change the value of total price, you can see that there is no item is returned.

29
00:02:13,730 --> 00:02:18,710
So as you can see that we can also run query with the filter expressions.

30
00:02:18,710 --> 00:02:24,710
But the important thing is when performing query operation, you should always pass the primary partition

31
00:02:24,710 --> 00:02:25,880
key and the sort key.
