Skip to main content
The explain() method shows the execution plan for a DataStore query, helping you understand what operations will be performed and what SQL will be generated.

Basic Usage

Syntax

Parameters:

Output Format

Standard Output

Icons Legend

Verbose Output

Verbose mode shows additional details for each operation, including the full SQL query with internal row-order tracking mechanisms.

Three Execution Phases

The explain output shows operations in three phases:

Phase 1: SQL Query Building (Lazy)

Operations that compile to SQL:

Phase 2: Execution Point

When a trigger occurs:

Phase 3: DataFrame Operations

Operations after execution:

Understanding the Plan

Source Information

  • file() - ClickHouse file() table function
  • 'CSVWithNames' - File format with header
Other source types:

Filter Operations

Shows the WHERE clause that will be applied.

GroupBy and Aggregate

Shows GROUP BY columns and aggregation functions.

Sort Operations

Shows ORDER BY clause.

Limit Operations

Shows LIMIT and OFFSET.

Engine Information

When using verbose mode, you can see which engine will be used:

Pushdown

  • Yes: Operation will be executed at the data source (SQL)
  • No: Operation requires pandas execution

Examples

Simple Query

Complex Aggregation

Mixed SQL and pandas

When operations cannot be fully pushed to SQL, the plan shows multiple segments:

Debugging with explain()

Check Filter Logic

Verify Column Selection

Understand Aggregation


Best Practices

  1. Check Before Executing Large Queries

  1. Use Verbose for Debugging

  1. Compare with to_sql()

  1. Check Pushdown Status

Last modified on July 2, 2026