"Union all" query seems to spend lot of time in "statistics" per profiling

Hi Folks,

Per the profiling, our “union all” queries seem to spend lot of time in “statistics”.

Copy/pasted that line.

| Status | Duration | Source_function | Source_file | Source_line |
| statistics | 0.000476 | optimize | sql_optimizer.cc | 530

The selects inside union all don’t have any joins, aggregations or subqueries.
The tables have only primary index. No secondary indexes. The PK has 4 columns. All selects have equality predicate on at least 1 column of PK.

Any idea why “union all” spending lot of time in “statistics”? Any config to reduce time spent in it.

Thanks,
Vamsi

1 Like

Also, our tables are RocksDB tables. In my previous post, I just showed one line from profiling for “statistics”. We see multiple such lines (as many as selects inside the union all).

Thanks,
Vamsi

1 Like