The number of worker threads for performing a query in an OceanBase tenant depends on the number of CPU cores in the tenant. Therefore, worker threads are a limited resource. If a query does not return results for a long time, the worker thread remains occupied. OceanBase designs a query timeout feature to release the worker threads and CPU resources occupied by a query that does not return results for a long time. By default, the timeout value is determined by the tenant variable ob_query_timeout. The default value is 100000000 (microseconds). When the query time exceeds this value, the error "4012(HY000): Timeout" is returned.
The default timeout parameter is appropriate for online transaction processing (OLTP) services, but not necessarily appropriate for online analytical processing (OLAP) services. In this case, you can adjust the value of the tenant variable at the session level or use an SQL hint to set the timeout parameter.
Example: Setting the query timeout value
obclient> show variables like 'ob_query_timeout';
+------------------+-----------+
| VARIABLE_NAME | VALUE |
+------------------+-----------+
| ob_query_timeout | 100000000 |
+------------------+-----------+
1 row in set (0.00 sec)
obclient> set session ob_query_timeout=1000000;
Query OK, 0 rows affected (0.00 sec)
obclient> select count(*) from hist a, hist b , hist c;
ERROR-00600: internal error code, arguments: -4012, Timeout
obclient>
obclient> select /*+ query_timeout(100000000) */ count(*) from hist a, hist b , hist c;
+----------+
| COUNT(*) |
+----------+
| 13824000 |
+----------+
1 row in set (3.34 sec)
obclient>