Reputation: 228
I have 20 tables in aws dynomodb.and everything was working very fine. but now it's not working and taking too much time for fetching data. I am not able to figure out where is the problem.
if the problem in my code then: Before it was working very fine I have not changed anything in the code.
if problem in dynamodb then: mobile side dynamodb queries working fine.as it was working for me. both mobile and website using the same database.
if the problem on my server then: after facing this problem I have created new instance.i have taken ubuntu, now everything working very fine expect dynamodb.
here I have placed a demo code that how I was getting data from dynamodb table.
require 'vendor/autoload.php';
use Aws\Common\Aws;
use Aws\DynamoDb\DynamoDbClient;
$aws = Aws::factory ( '/var/www/html/jackpot/id.php' );
$client = $aws->get ( 'DynamoDb' );
$iterator = $client->getIterator ( 'Scan', array (
'TableName' => 'iqjackpot-mobilehub-352703280-counter'
) );
foreach($iterator as $item){
$totalTicket = (int) $item['totalTickets']['N'];
$counterIds = (int) $item['counterId']['N']+1;
}
echo $totalTicket;
die;
I don't know what I am doing wrong and what to do now.i have been spent 2 days on this.if someone helps me, I will be very very thankful.
Upvotes: 1
Views: 6540
Reputation: 8140
You are using an AWS DynamoDB Scan function. DynamoDB scans are extremely slow.
From: AWS DynamoDB
In general, Scan operations are less efficient than other operations in DynamoDB. A Scan operation always scans the entire table or secondary index. It then filters out values to provide the result you want, essentially adding the extra step of removing data from the result set.
It is advised to use a DynamoDB Query. If your indexes are set correctly, it should go a lot faster!
Upvotes: 3