EXPLAIN

Syntax

  1. explain ::= EXPLAIN [ [ ANALYZE ] [ VERBOSE ] | ( option [ , ... ] ) ]
  2. statement
  3. | VERBOSE [ boolean ]
  4. | COSTS [ boolean ]
  5. | BUFFERS [ boolean ]
  6. | TIMING [ boolean ]
  7. | SUMMARY [ boolean ]
  8. | FORMAT { TEXT | XML | JSON | YAML }

explain

option

EXPLAIN - 图2

Execute the statement and show actual run times and other statistics.

Examples

Create a sample table.

  1. yugabyte=# INSERT INTO sample(k1, k2, v1, v2) VALUES (1, 2.0, 3, 'a'), (2, 3.0, 4, 'b'), (3, 4.0, 5, 'c');

Check the execution plan for simple select (condition will get pushed down).

    Foreign Scan on sample (cost=0.00..112.50 rows=1000 width=44)(1 row)

    • Check the execution plan for select with complex condition (second condition requires filtering).

    1. QUERY PLAN

    Check execution with ANALYZE option.

    1. ----------------------------------------------------------------------------------------------------------
    2. Foreign Scan on sample (cost=0.00..125.00 rows=1000 width=44) (actual time=6.483..6.487 rows=1 loops=1)
    3. Filter: (floor(((k2)::numeric + 1.5)) = (v1)::numeric)
    4. Planning time: 2.390 ms
    5. Execution time: 5.146 ms
    6. (4 rows)