Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS DynamoDB query too slow (using query, not Scan)

It's my first time with AWS Lambdas and DynamoDB, in Python.

I have my Table with only 474 records and a total weight of 890,4 kilobytes. The filtered selection is around only 380 records.

Quite small, but still it takes severall seconds to query. Really too slow.

I use a global secondary index, as it's supposed to be the way to filter the collection.

dynamo = boto3.resource('dynamodb', region_name='us-east-1',
     aws_access_key_id='my_key',
     aws_secret_access_key= 'my_key')

table = dynamodb.Table('my_table_name')

response = table.query(
    IndexName='venta_arge_ok-index',
    KeyConditionExpression=Key('venta_arge_ok').eq('True'))

When I test the Lambda in the console I get this figures:

  • Memory Size: 128 MB
  • Max Memory Used: 84

Run the test several times and got consistent times around 3 sec:

  • Duration: 3270.27 ms
  • Duration: 3069.37 ms
  • Duration: 3290.68 ms
  • Duration: 3013.34 ms
  • Duration: 3157.71 ms

What am I missing here? Thanks!

like image 741
Francisco Ghelfi Avatar asked Nov 27 '25 04:11

Francisco Ghelfi


1 Answers

As Noel Llevares pointed, the issue was related with memory size (and it's related CPU power increase).

The same Lambda gave the following results for each memmory size tested:

128 MB - 3 sec 256 MB - 1.5 sec 512 MB - 0.75 sec 1024 MB - 0.4 sec

like image 133
Francisco Ghelfi Avatar answered Nov 29 '25 17:11

Francisco Ghelfi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!