Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

04-query-test.js

Focus mode
04-query-test.js - Amazon DynamoDB

The 04-query-test.js program performs Query operations on TryDaxTable.

const AmazonDaxClient = require("amazon-dax-client"); var AWS = require("aws-sdk"); var region = "us-west-2"; AWS.config.update({ region: region, }); var ddbClient = new AWS.DynamoDB.DocumentClient(); var daxClient = null; if (process.argv.length > 2) { var dax = new AmazonDaxClient({ endpoints: [process.argv[2]], region: region, }); daxClient = new AWS.DynamoDB.DocumentClient({ service: dax }); } var client = daxClient != null ? daxClient : ddbClient; var tableName = "TryDaxTable"; var pk = 5; var sk1 = 2; var sk2 = 9; var iterations = 5; var params = { TableName: tableName, KeyConditionExpression: "pk = :pkval and sk between :skval1 and :skval2", ExpressionAttributeValues: { ":pkval": pk, ":skval1": sk1, ":skval2": sk2, }, }; for (var i = 0; i < iterations; i++) { var startTime = new Date().getTime(); client.query(params, function (err, data) { if (err) { console.error( "Unable to read item. Error JSON:", JSON.stringify(err, null, 2) ); } else { // Query succeeded } }); var endTime = new Date().getTime(); console.log( "\tTotal time: ", endTime - startTime, "ms - Avg time: ", (endTime - startTime) / iterations, "ms" ); }
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.