Courseiva
Using Spark SQL →mediumMultiple Choice

Databricks-Spark-Assoc Using Spark SQL Practice Question

When working with Delta Lake tables in Databricks, which command should you use to optimize the physical layout of files to improve query performance?

⚠ Common exam trap

Candidates often select 'VACUUM' or 'COMPACT' instead of 'OPTIMIZE'. They confuse the command for removing old files (VACUUM) with the command for improving query performance by compacting small files.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

OPTIMIZE table_name

Delta Lake provides the `OPTIMIZE` command to compact small files into larger ones, which is vital for maintaining performance as data grows. Frequent small writes can lead to file proliferation, degrading read speeds. Running `OPTIMIZE` regularly helps maintain efficient file sizes, enabling faster query execution by reducing metadata overhead and maximizing the benefits of data skipping through better file-level statistics.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    COMPACT TABLE table_name

    Why it's wrong here

    COMPACT is not a valid SQL command in Databricks for Delta tables. While the concept of compaction is correct, the specific command implemented in Delta Lake is 'OPTIMIZE'. Using incorrect syntax will result in a parsing error, preventing the necessary file management tasks from being completed successfully.

  • ✓

    OPTIMIZE table_name

    Why this is correct

    The OPTIMIZE command is the standard Delta Lake operation used to coalesce small files into larger, more performant files. It is an essential maintenance task for Databricks environments to ensure that storage layouts remain optimized for analytical queries, which significantly reduces the time spent on I/O operations.

  • ✗

    REORGANIZE TABLE table_name

    Why it's wrong here

    REORGANIZE is used for specific Delta features like data skipping or Z-Order management in certain contexts, but it is not the primary command for general file compaction. OPTIMIZE is the specific tool designed for the purpose of merging small files to improve read performance across the board.

  • ✗

    VACUUM table_name

    Why it's wrong here

    VACUUM is used to remove stale files that are no longer referenced by the Delta log and are older than the retention threshold. While it manages disk space, it does not perform file compaction or reorganization to improve query performance; it is purely a cleanup and cost-management utility.

About these practice questions

Courseiva writes every Databricks-Spark-Assoc question from scratch — 295 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Databricks exam blueprint

This Databricks-Spark-Assoc practice question is part of Courseiva's free Databricks certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the Databricks-Spark-Assoc exam.