Study guide
Technical reference and lesson notes
Purpose of This Lesson
S3 Select and S3 Glacier Select are designed to retrieve only a relevant subset of data from an object instead of transferring the entire object to the application. This can reduce network transfer, processing, and application-side filtering when the object is stored in a supported format.
The key service-selection decision is based on where the data resides:
- Use S3 Select for objects stored in Amazon S3.
- Use S3 Glacier Select for archived objects stored in S3 Glacier storage classes.
A workload such as AWS Lambda can submit a SQL expression and process the returned records. However, these services are object-content query features—not general-purpose SQL databases and not a universal mechanism for extracting arbitrary files from ZIP archives.
Key Concepts
S3 Select
S3 Select allows an application to use a SQL-like expression to filter and project data from a single S3 object. Instead of downloading the complete object, the application requests only the matching records or columns.
Typical supported data formats include:
- CSV
- JSON
- Apache Parquet
Depending on the format and configuration, compression may also be supported. The object must conform to the format and query requirements supported by S3 Select.
An application or AWS Lambda function can call the S3 Select API, provide the object location and SQL expression, and consume the returned records. S3 Select is most useful when:
- The object is large.
- Only a small portion of its contents is needed.
- The data has a structured, supported format.
- Downloading and filtering the entire object would be inefficient.
S3 Glacier Select
S3 Glacier Select provides a similar filtering capability for archived data. A query is submitted against an archive, and the service returns only the matching data rather than requiring the application to retrieve and process the complete archive.
Unlike a normal S3 object request, Glacier retrieval is generally an asynchronous operation. The workflow typically involves:
- Submit a select or retrieval job with the archive and SQL expression.
- Wait for the job to complete according to the selected retrieval tier.
- Retrieve the job output from the configured destination.
This model is appropriate when the data is archived and access is infrequent enough that retrieval latency and retrieval charges are acceptable.
Object-Level Filtering Is Not ZIP File Browsing
A common oversimplification is to describe Select as a way to retrieve an individual file from inside any ZIP archive. Select queries supported object formats and records; it is not a general ZIP-member extraction API.
If an archive contains many independent files inside a ZIP container, consider alternatives such as:
- Extracting the files before ingestion and storing them as separate S3 objects.
- Maintaining an index or manifest of archive contents.
- Using AWS Glue, Amazon Athena, AWS Batch, or another processing service where appropriate.
- Running a custom decompression workflow in Lambda, Amazon ECS, or AWS Batch, subject to runtime, memory, and temporary-storage limits.
S3 Select Versus Athena
S3 Select is scoped to a single object. Amazon Athena is designed to query datasets across many S3 objects using tables, schemas, and partitions.
Use S3 Select when the application already knows the target object and needs a subset of its contents. Use Athena when the requirement is analytical querying across a data lake or multiple objects.
Architecture Decision Guide
| Requirement | Better fit | Reason |
|---|---|---|
| Filter rows from one structured object in S3 | S3 Select | Returns only matching content from a single object |
| Query archived data without restoring the entire archive to the application | S3 Glacier Select | Performs filtering as part of an archive retrieval job |
| Query many objects across a data lake | Amazon Athena | Provides SQL queries across S3 datasets |
| Extract arbitrary files from a ZIP archive | Custom processing workflow | Select is not a general ZIP archive browser |
| Repeated low-latency access to individual records | DynamoDB, OpenSearch, or a database | Object storage query features are not a replacement for an indexed database |
| Process a large archive with complex transformations | AWS Glue, AWS Batch, or Amazon EMR | Better suited to multi-step or distributed processing |
Exam-Relevant Takeaways
- S3 Select queries content from an object stored in Amazon S3.
- S3 Glacier Select applies the same general filtering concept to archived data, but retrieval is typically job-based and asynchronous.
- Both services use SQL-like expressions to reduce the amount of data returned to the requesting application.
- Select is most valuable when only a small subset of a large, supported-format object is required.
- S3 Select is not the same as Amazon Athena: Select targets one object, while Athena can query datasets spanning many objects.
- Do not assume Select can extract arbitrary members from a ZIP file. Verify the supported input format and compression requirements.
- Glacier retrieval latency, retrieval tier, output handling, and cost are part of the architecture decision.
- If records require frequent indexed lookups, store them in a purpose-built database rather than repeatedly querying large S3 objects.
Common Exam Traps
- Confusing S3 Select with Athena: S3 Select is object-scoped; Athena is dataset-scoped.
- Assuming Select is a database: Select does not provide persistent indexes, transactions, updates, or general relational database capabilities.
- Treating Glacier Select as synchronous: Archived-data operations commonly require a retrieval or select job and later collection of the results.
- Assuming any file format works: The object must use a supported format such as CSV, JSON, or Parquet, with compatible serialization and compression settings.
- Assuming ZIP member extraction is automatic: A ZIP containing multiple files may need custom processing or a different ingestion design.
- Ignoring archive retrieval economics: Glacier storage can reduce storage cost, but retrieval time and request/output charges can make it unsuitable for interactive access.
- Choosing Select for repeated queries: Repeated or broad queries may be better served by Athena with partitioning or by loading data into an analytical or transactional data store.
Real-World Engineer Notes
- Store data in query-friendly formats during ingestion rather than creating opaque archives that must be decompressed later.
- For analytical workloads, columnar formats such as Parquet can reduce scanned data when the query needs only selected columns.
- If Lambda invokes S3 Select, grant the function only the required S3 permissions and ensure the object key and bucket are constrained by IAM policies where possible.
- For Glacier Select workflows, design for asynchronous completion, retries, notification, and durable result handling.
- Keep manifests or metadata that identify archive contents if compliance or retention requirements require data to remain packaged.
- Validate the actual service availability and supported features for the target AWS account and Region. S3 Select availability and onboarding status may change, so current AWS documentation should be checked before adopting it for a new design.
- Measure end-to-end cost: request charges, bytes scanned, bytes returned, retrieval charges, temporary processing, and downstream storage can outweigh the savings from avoiding a full download.
Quick Reference Summary
- S3 Select: SQL-like filtering of a single supported-format S3 object.
- S3 Glacier Select: SQL-like filtering of archived data through a retrieval/select job.
- Primary benefit: Return less data and reduce application-side processing.
- Typical caller: An application, Lambda function, or other service using the relevant API.
- Main limitation: Not a general SQL database or universal archive/file extraction service.
- Use Athena instead: When querying multiple S3 objects or a data lake.
- Use custom processing instead: When extracting arbitrary ZIP members or performing complex transformations.
Flashcards
- Q: What does S3 Select do?
A: It filters and projects data from a single S3 object using a SQL-like expression, returning only the requested results.
- Q: What does S3 Glacier Select do?
A: It filters data stored in an archived object and returns matching results through an archive retrieval/select job.
- Q: What is the main difference between S3 Select and Athena?
A: S3 Select targets one object; Athena queries datasets that can span many S3 objects.
- Q: Name common formats supported by Select features.
A: CSV, JSON, and Apache Parquet, subject to the specific API and configuration requirements.
- Q: Why use S3 Select instead of downloading an entire object?
A: To reduce transferred bytes, client-side processing, and potentially network and compute costs.
- Q: Is S3 Select a general-purpose ZIP extraction service?
A: No. It queries supported object data formats and is not a universal API for extracting arbitrary ZIP members.
- Q: Why is Glacier Select commonly asynchronous?
A: Archived data may need retrieval processing, which takes time depending on the storage class and retrieval tier.
- Q: When is a database preferable to S3 Select?
A: When the application needs frequent low-latency lookups, indexes, updates, transactions, or relationship-aware queries.
- Q: What should an engineer consider before using Glacier Select?
A: Retrieval latency, retrieval tier, request and output costs, job handling, and whether the workload can tolerate asynchronous access.
- Q: What is a better option for querying many partitioned S3 datasets?
A: Amazon Athena, often combined with AWS Glue Data Catalog and an efficient data layout such as Parquet and partitions.
Practice Questions
Question 1
A Lambda function must retrieve a small subset of records from a large CSV object stored in Amazon S3. Downloading the entire object would consume excessive bandwidth and memory. Which solution best meets the requirement?
A. Use Amazon Athena for every Lambda invocation without creating a dataset definition
B. Use S3 Select with a SQL-like expression targeting the object
C. Move the object to S3 Glacier Flexible Retrieval and use a bulk retrieval
D. Copy the object to Amazon EBS and query it from Lambda
Correct answer: B
Explanation: S3 Select is designed to filter data from a single supported-format S3 object and return only matching records. Athena is better for queries across datasets, while Glacier retrieval and EBS add unnecessary complexity.
Question 2
A company stores compliance data in an S3 Glacier storage class. An application occasionally needs only records matching a predicate and can tolerate an asynchronous workflow. Which service capability should the architect evaluate?
A. S3 Glacier Select
B. S3 Transfer Acceleration
C. Amazon RDS read replicas
D. S3 multipart upload
Correct answer: A
Explanation: S3 Glacier Select can query archived data and return matching results through a retrieval/select job. The design must account for retrieval latency and charges.
Question 3
An organization stores millions of log files inside large ZIP archives in S3. A new application must retrieve one individual log file by its filename with low latency. Which recommendation is most appropriate?
A. Assume S3 Select can extract any ZIP member directly
B. Use S3 Glacier Select regardless of the archive storage class
C. Store individual logs as separately addressable S3 objects or build a purpose-designed indexing and extraction workflow
D. Use Athena to treat every ZIP member as an independent table row automatically
Correct answer: C
Explanation: Select is not a universal ZIP-member extraction API, and Athena does not automatically expose arbitrary files inside ZIP containers as rows. Separately stored objects or a custom indexed workflow provides a design that matches low-latency individual retrieval.
Question 4
A data platform needs SQL queries joining and filtering records across thousands of Parquet objects in an S3 data lake. Which option is the best fit?
A. S3 Select invoked once for each object by a client-side loop
B. Amazon Athena with an appropriate catalog, schema, and partition strategy
C. S3 Glacier Select on each object
D. S3 object versioning
Correct answer: B
Explanation: Athena is intended for SQL analytics across multiple S3 objects. Invoking S3 Select separately for thousands of objects would create unnecessary orchestration and is not the natural service for cross-object analytics.
Question 5
A team proposes S3 Select for a workload that performs thousands of interactive point lookups per second and requires updates and secondary indexes. What should the architect recommend?
A. Use S3 Select because S3 automatically creates indexes for SQL expressions
B. Use S3 Glacier Select because archived objects provide lower latency
C. Use a purpose-built database or indexed data service and retain S3 for durable object storage
D. Compress all objects more aggressively
Correct answer: C
Explanation: S3 Select is an object-content filtering mechanism, not a low-latency transactional or indexed database. A database or search service is more appropriate for frequent point lookups, updates, and secondary indexes.