Reputation: 1971
I am using DynamoDB as backend for android platform. We are able to create the table and perform the query on it. I see that the fetching the data from the table take time in android side. I want to share more detail about the table schema here.
We have two table 1) video 2) classification. We want to fetch the video list based on given classification.
We have different kind of classification. i.e Weekly shows, Popular shows etc. each section contains the video id from video table.
In android side integrated the AWS mobile SDK. I can share the query code snippet that take time for fetching the data.
Query : Fetch the video list based on the classification. The classification table contains the video_id
List<VideosData> mVideosList = new ArrayList<>();
DynamoDBMapper dynamoDBMapper = new DynamoDBMapper(voids[0]);
DynamoDBQueryExpression<Classification> classificationQuery = new DynamoDBQueryExpression<>();
classificationQuery.withHashKeyValues(new Classification().setClassification_id(mType));
List<Classification> classifications = dynamoDBMapper.query(Classification.class, classificationQuery);
if (classifications != null && classifications.size() > 0) {
for (Classification rows : classifications) {
DynamoDBQueryExpression<VideosData> videosExpression = new DynamoDBQueryExpression<>();
videosExpression.withHashKeyValues(new VideosData().setVideoId(rows.getVideo_id()));
List<VideosData> tempDatas = dynamoDBMapper.query(VideosData.class, videosExpression);
mVideosList.addAll(tempDatas);
}
}
Any suggestion will appreciate for optimization. I am beginning level in DynamoDB AWS that's might be the problem to understand it.
Update : Is there any read and write capacity unit over the table need to have set for increase the performance?
Thank you. Bhavdip
Upvotes: 0
Views: 130
Reputation: 803
The code looks fairly sensible as you're using Queries instead of a scan. The two initial thoughts I have, both on the Dynamo side rather than client, are:
How are you defining the keys on the tables, especially the Classification table. You say the category id in combination with the video ID are the primary key, but do you mean one is a Hash key and one is a range key? If the category_id
is being used as the partitioning key this could cause problems if it's not randomly distributed enough.
You're right to point out that read and write capacities can be a bottleneck. You should be able to see what you're consuming of these overall on the AWS console. However, as noted in the link above, if your records aren't randomly distributed throughout the partitions, then one partition may be getting hit disproportionately. This can cause bottlenecking, without showing the overall capacity being consumed.
Upvotes: 1