The projection determines the attributes that you will be able to retrieve with the most efficiency. The set of attributes that is copied into a local secondary index is called a projection. For more information, see the FAQ items below about item collections. They introduce some constraints on the volume of data you can store within a single partition key value. Local secondary indexes are not appropriate for every application. You can also redundantly store other data attributes in the local secondary index, in order to access those other attributes without having to access the table itself.
#LOCAL DYNAMODB METRICS PLUS#
These attributes include the table partition and sort key, plus the alternate sort key you define. Redundant copies of data attributes are copied into the local secondary indexes you define. So while previously you could only search using the partition key and the sort key, now you can also search using a secondary index in place of the sort key, thus expanding the number of attributes that can be used for queries which can be conducted efficiently. We call this new secondary index a ‘local’ secondary index because it is used along with the partition key and hence allows you to search locally within a partition key bucket. Moreover, it also simplifies the programming model for your application as you no longer have to write customer logic to filter the results.
This significantly reduces the latency and cost of your queries as you will retrieve only items that meet your specific criteria. Now, you can create an index on "shipping date" attribute and execute this query efficiently and just retieve only the necessary items. With local secondary indexes, we are simplifying this experience. Without LSI, to find an answer to the question "Display all orders made by Customer X with shipping date in the past 30 days, sorted by shipping date", you had to use the Query API to retrieve all the objects under the partition key "X", sort the results by shipment date and then filter out older records. For instance, consider an e-commerce application that stores customer order data in a DynamoDB table with partition-sort schema of customer id-order timestamp. It means your applications can rely on more flexible queries based on a wider range of attributes.īefore the launch of local secondary indexes, if you wanted to find specific items within a partition (items that share the same partition key), DynamoDB would have fetched all objects that share a single partition key, and filter the results accordingly. Sam Local TestingĪdding a test-event.Local secondary indexes enable some common queries to run more quickly and cost-efficiently, that would otherwise require retrieving a large number of items and then filtering the results. I'll perhaps do some comparisons later in the series. I've found that Lambdas running on this not only run faster than on x86, but are also less expensive. One interesting thing to note here is that I'm using the 'arm64' architecture. Timeout: 30 MemorySize: 512 Policies: - AWSLambdaBasicExecutionRole Metadata: BuildMethod: makefile
Timeout: 30 MemorySize: 512 Policies: - AWSLambdaBasicExecutionRole Metadata: BuildMethod: makefile BlasterLambdaTS: Type: AWS::Serverless::Function Properties: Architectures: - arm64 Handler: Runtime: nodejs14.x CodeUri. Template.yml: AWSTemplateFormatVersion: "" Transform: - "AWS::Serverless-" Resources: BlasterLambdaRust: Type: AWS::Serverless::Function Properties: Architectures: - arm64 Handler: none Runtime: provided.al2 CodeUri. target/aarch64-unknown-linux-gnu/release/blaster_handler $(ARTIFACTS_DIR)/bootstrap
v " $(PWD)":/usr/src/myapp -w /usr/src/myapp rust:latest \Ĭargo build -release -target aarch64-unknown-linux-gnuĬp.
I want to be able to build everything with just the 'sam build' command, so I use a Makefile to do this.Ĭp.
#LOCAL DYNAMODB METRICS INSTALL#
Npm install -save-dev Lambda DependenciesĪdding Lambda event type definitions: npm install -save-dev a Webpack config so I can minimize my TS Lambda size (): const path = require( 'path') Initialize Typescript and Webpack: npm init Initialize the ProjectĬreate a new Rust project: cargo new sqs_ddb_rust -bin While I'm at it, I'll do a performance shootout between Rust and Typescript versions, attempting to optimize each as much as possible to create a fair comparison. In this series, I will be investigating throughput tuning for a Lambda that receives SQS events, reads data from S3 object, and blasts the data into DynamoDB.