log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
# and their durations, > 0 logs only
# statements running at least this number
# of milliseconds
####
echo "
create table t(n integer primary key);
insert into t select * from generate_series(1,10000);
analyze t; --> gather table statistics
explain (analyze, verbose, format yaml) select count(*) from t where n between 10 and 20;
" | psql -qtAX
####
- Plan:
Node Type: "Aggregate"
Strategy: "Plain"
Partial Mode: "Simple"
Parallel Aware: false
Startup Cost: 8.51
Total Cost: 8.52
Plan Rows: 1
Plan Width: 8
Actual Startup Time: 0.040
Actual Total Time: 0.040
Actual Rows: 1
Actual Loops: 1
Output:
- "count(*)"
Plans:
- Node Type: "Index Only Scan"
Parent Relationship: "Outer"
Parallel Aware: false
Scan Direction: "Forward"
Index Name: "t_pkey"
Relation Name: "t"
Schema: "public"
Alias: "t"
Startup Cost: 0.29
Total Cost: 8.48
Plan Rows: 10
Plan Width: 0
Actual Startup Time: 0.022
Actual Total Time: 0.029
Actual Rows: 11
Actual Loops: 1
Output:
- "n"
Index Cond: "((t.n >= 10) AND (t.n <= 20))"
Rows Removed by Index Recheck: 0
Heap Fetches: 11
Planning Time: 0.481
Triggers:
Execution Time: 0.149