AWS Certified Data Engineer Associate 2026 - Hands On!

Database Performance Optimization: Indexing, Partitioning, and Compression

Learn how indexing, partitioning, compression, and columnar compression improve database performance while balancing scan volume, storage, disk I/O, CPU usage, and data lifecycle needs.

AWS Certified Data Engineer Associate 2026 - Hands On!AWS Certified Data Engineer Associate 2026 - Hands On!Updated Aug 17, 2026
Study options
WatchComing later
ListenComing later
ReadAvailable
ReviewComing later

Study guide

Technical reference and lesson notes

Database Performance Optimization

Purpose of This Lesson

Database performance optimization focuses on reducing unnecessary data access and making storage and query processing more efficient. The three primary techniques in this lesson are indexing, partitioning, and compression.

For AWS Certified Data Engineer Associate preparation, the key skill is recognizing which technique addresses a particular bottleneck: lookup efficiency, scan volume, data lifecycle, parallel processing, storage usage, or disk I/O.

Key Concepts

Indexing

Indexes help a database locate required rows without scanning every row in a table. A full table scan may be unavoidable in some cases, but it should not be the default when queries repeatedly search or filter on specific attributes.

Effective indexing requires understanding the workload:

  • Review the queries that users and applications actually run.
  • Identify the columns commonly used to search or filter data.
  • Build indexes that support those access patterns.
  • Monitor index creation for conflicts that may reveal duplicate values or data-integrity problems.

Indexes can also help enforce uniqueness and expose data-quality issues. An indexing conflict may indicate that the data contains values that violate an intended uniqueness rule.

Partitioning

Partitioning divides a large dataset into logical sections based on a selected attribute, such as date. Queries that restrict their search to a particular partition can scan less data.

For example, if data is commonly queried by month, monthly partitions can limit the amount of data scanned for a one-month request. Partitioning is particularly useful when the query pattern aligns with the partition key.

Partitioning can also support:

  • Data lifecycle management: Older time-based partitions can be moved to less expensive storage or deleted when appropriate.
  • Storage-cost control: Retaining older data in cheaper storage can reduce ongoing costs.
  • Compliance-related retention handling: Partitions can make age-based retention actions easier to manage, subject to applicable requirements.
  • Parallel processing: Logically separate partitions may be processed alongside one another.

Partitioning does not automatically improve every query. Its benefit depends on whether queries can use the partition boundaries to avoid scanning unrelated data.

Compression

Compression reduces the amount of data stored and transferred. It can also reduce disk reads, which is important when database performance is limited by disk I/O.

Compression introduces a tradeoff. More complex compression may reduce storage and I/O but require more CPU to compress or decompress. Excessive compression can shift the bottleneck from I/O to CPU.

Compression formats mentioned for Amazon Redshift include:

  • GZIP
  • LZOP
  • BZIP2
  • Zstandard

The appropriate choice balances compression efficiency with processing speed.

Columnar Compression

Columnar data formats such as Parquet store values from the same column together. Because values in a column often share a data type and have similar structure, columnar compression can be more efficient than compressing a row containing many different types of information.

Columnar storage and compression are especially relevant to analytical workloads, where queries often read selected columns rather than complete rows.

Performance Optimization Context

Performance problems often arise because a system is reading or transferring more data than necessary. The techniques in this lesson address different parts of that problem:

TechniquePrimary benefitMain consideration
IndexingFaster targeted lookups and filteringIndexes must match actual query patterns and can reveal uniqueness conflicts
PartitioningFewer rows or files considered during a queryThe partitioning scheme must align with common filters
CompressionLess storage, transfer, and disk I/OCPU cost can become the new bottleneck
Columnar compressionEfficient compression of same-type column valuesBest understood alongside columnar storage such as Parquet

A practical optimization process begins with the observed workload and bottleneck rather than choosing a technique solely because it is available.

Exam- or Assessment-Relevant Takeaways

  • A query that searches every row when a selective lookup is possible suggests a need to review indexing.
  • Index design should be based on query patterns, not arbitrary columns.
  • Partitioning is most effective when queries commonly filter on the partitioning attribute.
  • Time-based partitioning can reduce scans for recent data and simplify aging, movement, or deletion of older data.
  • Partitioning may enable parallel processing when independent partitions can be processed concurrently.
  • Compression is useful when storage, transfer, or disk I/O is a limiting factor.
  • Compression is not free: a highly complex format can make CPU the bottleneck.
  • GZIP, LZOP, BZIP2, and Zstandard are compression formats identified in the lesson as supported by Amazon Redshift.
  • Columnar compression can be efficient because values in the same column tend to have consistent types and structures.
  • Do not confuse reducing scanned data through partitioning with accelerating a specific row lookup through indexing.

Tool / Feature Decision Guide

Choose Indexing When

Use indexing when the workload performs repeated targeted searches or filters and a full table scan is unnecessary. Confirm that the proposed index supports actual query predicates and that uniqueness requirements are understood.

Choose Partitioning When

Use partitioning when the dataset is large and queries naturally restrict data by a meaningful partition key, such as a date range. Partitioning is also a strong fit when data must be managed by age or when independent subsets can be processed in parallel.

Choose Compression When

Use compression when disk I/O, storage consumption, or data transfer is a significant concern. Select a format that provides useful reduction without imposing excessive CPU overhead.

Combine Techniques When Appropriate

These techniques solve different problems and can be used together. For example, a large time-partitioned dataset may reduce the amount of data considered by a query, while indexes support targeted access within the relevant data and compression reduces storage and disk reads. The lecture does not prescribe one universal combination; the workload and bottleneck determine the design.

Common Traps / Misconceptions

  • Assuming every full table scan is automatically wrong: The important question is whether the scan could reasonably be avoided for the workload.
  • Creating indexes without studying queries: An index is useful only when it supports actual access patterns.
  • Treating partitioning as a replacement for indexing: Partitioning reduces the scope of data considered; it does not serve the same role as an index.
  • Partitioning on an attribute that queries do not use: If filters do not align with the partition key, scan reduction may be limited.
  • Assuming stronger compression is always faster: Compression can reduce I/O while increasing CPU work.
  • Ignoring data-integrity signals from index conflicts: A uniqueness conflict may reveal duplicate or invalid data that requires investigation.
  • Forgetting lifecycle benefits: Time-based partitions can help with storage-tier movement and deletion, not just query performance.
  • Assuming row compression and columnar compression behave identically: Columnar data may compress more efficiently because values of the same type are grouped together.

Real-World Engineer / Analyst Notes

  1. Start with the workload: identify the queries, filters, scan behavior, and dominant resource constraint.
  2. Use indexing to improve targeted access, partitioning to reduce the data scope, and compression to reduce the physical amount of data read or transferred.
  3. Treat partition design as both a query-performance and data-lifecycle decision when using time-based data.
  4. Watch for bottleneck displacement. A compression choice that lowers disk I/O may increase CPU usage enough to reduce overall performance.
  5. Use data-integrity conflicts as diagnostic signals rather than treating them only as configuration failures.
  6. For analytical data, consider how columnar storage and columnar compression work together, particularly with formats such as Parquet.

Quick Reference Summary

  • Indexing: Avoids unnecessary full table scans for targeted lookups and can support uniqueness and integrity checks.
  • Partitioning: Divides large data volumes into logical segments, often by date, to reduce scans and support lifecycle management or parallel processing.
  • Compression: Reduces storage, transfer, and disk reads but may increase CPU usage.
  • Columnar compression: Benefits from grouping same-type values together in columnar formats such as Parquet.
  • Redshift formats named in the lesson: GZIP, LZOP, BZIP2, and Zstandard.
  • Selection rule: Match the technique to the bottleneck and the query or processing pattern.

Flashcards

Q: A query repeatedly searches for specific records, but the database scans every row in the table. Which optimization should be investigated first, and why?

A: Investigate indexing. A suitable index can support targeted access and avoid unnecessary full table scans.

Q: What should determine which columns receive indexes?

A: The actual query workload should determine index selection, especially the columns commonly used for searches and filters.

Q: How can an indexing conflict provide useful information beyond a failed index operation?

A: It may reveal duplicate values or another data-integrity problem that was previously unknown.

Q: A large dataset is usually queried for one month at a time. Which partitioning strategy is a logical candidate?

A: Time-based monthly partitioning is a logical candidate because queries for one month can avoid considering unrelated months.

Q: When is partitioning likely to provide limited benefit?

A: It may provide limited benefit when queries do not filter on, or otherwise align with, the partitioning attribute.

Q: How can time-based partitions support data lifecycle management?

A: Older partitions can be moved to less expensive storage or deleted over time, depending on retention and compliance needs.

Q: What is the difference between partitioning and indexing as performance techniques?

A: Partitioning reduces the amount of data considered by dividing it into logical sections, while indexing accelerates targeted access within the data based on lookup patterns.

Q: What additional processing benefit can logically designed partitions provide?

A: Independent partitions may be processed in parallel, allowing separate portions of the dataset to be handled alongside one another.

Q: When is compression especially valuable for database performance?

A: Compression is especially valuable when storage, data transfer, or disk I/O is limiting performance because it reduces the amount of physical data involved.

Q: What is the main performance tradeoff of using a more complex compression format?

A: It may reduce storage and I/O but require more CPU for compression or decompression, potentially changing an I/O-bound system into a CPU-bound one.

Q: Which compression formats are identified in the lesson as supported by Amazon Redshift?

A: GZIP, LZOP, BZIP2, and Zstandard are the formats named in the lesson.

Q: Why can columnar compression be more efficient than compressing a mixed row?

A: Values from the same column tend to share a data type and similar structure, making them more uniform and often easier to compress.

Practice Questions

Question 1

An analytical table contains several years of records, but most queries request only the previous month. Which design decision most directly reduces the amount of data considered by those queries?

A. Use a more complex compression format only
B. Create time-based partitions aligned with the query period
C. Remove all indexes from the table
D. Store every row with additional mixed-format attributes

Correct answer: B

Explanation: Time-based partitions can limit the query to the relevant period instead of considering all years of data.

Question 2

A database is experiencing high disk I/O and slow data transfers. The team is considering compression, but CPU usage is already a concern. What is the best conclusion from the lesson?

A. Compression should always be maximized regardless of CPU cost
B. Compression is irrelevant to disk I/O
C. The team should balance I/O reduction against the CPU cost of the chosen format
D. Partitioning automatically resolves all CPU and I/O problems

Correct answer: C

Explanation: Compression can reduce storage, transfer, and disk reads, but an overly complex format may shift the bottleneck to CPU.

Question 3

A data engineer creates an index and receives a conflict caused by duplicate values. What should the engineer infer first?

A. The database cannot use indexes for performance
B. The conflict may expose a data-integrity or uniqueness problem
C. The table must be partitioned by CPU usage
D. Compression has corrupted the table

Correct answer: B

Explanation: Indexing can enforce uniqueness, so a conflict may reveal duplicate or otherwise invalid data that needs investigation.

Question 4

A team wants to accelerate queries that retrieve selected columns from a large analytical dataset stored in Parquet. Why may columnar compression be a suitable consideration?

A. Columns group values with similar types and structures
B. Columnar compression guarantees that no scan will occur
C. Parquet requires every row to contain the same mixed data
D. Columnar compression eliminates all CPU usage

Correct answer: A

Explanation: Grouping same-column values can make compression more efficient. It does not guarantee that scans or CPU work disappear.

WordPress Metadata

Suggested Slug:
database-performance-optimization-indexing-partitioning-compression

Meta Description:
Learn how indexing, partitioning, compression, and columnar compression improve database performance while balancing scan volume, storage, disk I/O, CPU usage, and data lifecycle needs.

Tags:
AWS, data engineering, database performance, indexing, partitioning, compression, Amazon Redshift, Parquet, disk I/O, query optimization, data lifecycle, AWS Certified Data Engineer