Does the database support caching query results?
The database does not directly cache final query results. From v2.5 onwards, the database uses the Query Cache feature to save the intermediate results of first-stage aggregation in the cache. New queries that are semantically equivalent to previous queries can reuse the cached computation results to accelerate computations. Query cache uses BE memory. For more information, see Query cache.When a Null is included in the calculation, the calculation results of functions are false except for the ISNULL() function
In standard SQL, every calculation that includes an operand with a NULL value returns a NULL.
Does the database support the DECODE function?
The database does not support the DECODE function of the Oracle database. The database is compatible with MySQL, so you can use the CASE WHEN statement.Can the latest data be queried immediately after data is loaded into the Primary Key table of the database?
Yes. The database merges data in a way that references Google Mesa. In the database, a BE triggers the data merge and it has two kinds of compaction to merge data. If the data merge is not completed, it is finished during your query. Therefore, you can read the latest data after data loading.Do the utf8mb4 characters stored in the database get truncated or appear garbled?
No.This error “table’s state is not normal” occurs when I run the alter table command
This error occurs because the previous alteration has not been completed. You can run the following code to check the status of the previous alteration:
This error “get hive partition meta data failed: java.net.UnknownHostException:hadooptest” occurs when I query the external tables of Apache Hive
This error occurs when the metadata of Apache Hive partitions cannot be obtained. To solve this problem, copy core-sit.xml and hdfs-site.xml to the fe.conf file and the be.conf file.When cardinality of column A is small, the query results of select B from tbl order by A limit 10 vary each time
SQL can only guarantee that column A is ordered, and it cannot guarantee that the order of column B is the same for each query. MySQL can guarantee the order of column A and column B because it is a standalone database.
The database is a distributed database, of which data stored in the underlying table is in a sharding pattern. The data of column A is distributed across multiple machines, so the order of column B returned by multiple machines may be different for each query, resulting in inconsistent order of B each time. To solve this problem, change select B from tbl order by A limit 10 to select B from tbl order by A,B limit 10.
Why is there a large gap in column efficiency between SELECT * and SELECT?
To solve this problem, check the profile and see MERGE details:- Check whether the aggregation on the storage layer takes up too much time.
- Check whether there are too many indicator columns. If so, aggregate hundreds of columns of millions of rows.
Does DELETE support nested functions?
Nested functions are not supported, such asto_days(now()) in DELETE from test_new WHERE to_days(now())-to_days(publish_time) >7;.
How to improve the usage efficiency of a database when there are hundreds of tables in it?
To improve efficiency, add the-A parameter when you connect to MySQL’s client server: mysql -uroot -h127.0.0.1 -P8867 -A. MySQL’s client server does not pre-read database information.
How to reduce the disk space occupied by the BE log and the FE log?
Adjust the log level and corresponding parameters. For more information, see Parameter Configuration.This error “table *** is colocate table, cannot change replicationNum” occurs when I modify the replication number
When you create colocated tables, you need to set thegroup property. Therefore, you cannot modify the replication number for a single table. You can perform the following steps to modify the replication number for all tables in a group:
- Set
group_withtoemptyfor all tables in a group. - Set a proper
replication_numfor all tables in a group. - Set
group_withback to its original value.
Does setting VARCHAR to the maximum value affect storage?
VARCHAR is a variable-length data type, which has a specified length that can be changed based on the actual data length. Specifying a different varchar length when you create a table has little impact on the query performance on the same data.This error “create partititon timeout” occurs when I truncate a table
To truncate a table, you need to create the corresponding partitions and then swap them. If there are a larger number of partitions that need to be created, this error occurs. In addition, if there are many data load tasks, the lock will be held for a long time during the compaction process. Therefore, the lock cannot be acquired when you create tables. If there are too many data load tasks, settablet_map_shard_size to 512 in the be.conf file to reduce the lock contention.
This error “Failed to specify server’s Kerberos principal name” occurs when I access external tables of Apache Hive
Add the following information to hdfs-site.xml in the fe.conf file and the be.conf file:Is “2021-10” a date format in the database?
No.Can “2021-10” be used as a partition field?
No, use functions to change “2021-10” to “2021-10-01” and then use “2021-10-01” as a partition field.Where can I query the size of a database or table?
You can use the SHOW DATA command.SHOW DATA; displays the data size and replicas of all tables in the current database.
SHOW DATA FROM <db_name>.<table_name>; displays the data size, number of replicas, and number of rows in a specified table of a specified database.
In the database on ES, when creating an Elasticsearch external table, if the relevant string length is too long, exceeding 256, and Elasticsearch uses dynamic mapping, using a select statement will result in the inability to query that column
In dynamic mapping, Elasticsearch’s data type isHow to quickly count the size of databases and tables and the disk resources they occupy?
You can use the SHOW DATA command to view the storage size of databases and tables.SHOW DATA; displays the data volume and replica count of all tables in the current database.
SHOW DATA FROM <db_name>.<table_name>; displays the data volume, replica count, and row count of a specific table in a specified database.
Why does using a function on a partition key slow down queries?
Using a function on a partition key can lead to inaccurate partition pruning, thereby reducing query performance.Why doesn’t the DELETE statement support nested functions?
column op literal type and cannot be expressions. There are currently no plans to support expressions as comparison values.
How to name columns with reserved keywords?
Reserved keywords (e.g.,rank) need to be escaped, such as using `rank`.
How to stop an executing SQL?
You can useshow processlist; to view executing SQL and use kill <id>; to terminate the corresponding SQL. You can also view and manage through SHOW PROC '/current_queries';.
How to clean up idle connections?
You can control the timeout for idle connections through the session variablewait_timeout (unit: seconds). MySQL automatically cleans up idle connections after about 8 hours by default.
Are multiple SQL segments in UNION ALL executed in parallel?
Yes, they are executed in parallel.What should be done if a SQL causes BE to crash?
- Based on the
be.outerror stack, find thequery_idthat caused the crash. - Find the corresponding SQL in
fe.audit.logusing thequery_id.
be.outlog- Run
pstack $be_pid > pstack.logto execute SQL. - Core Dump file
-
Get the corresponding BE process:
-
Set the Core file size limit to unlimited.
Verify if the size limit is unlimited.
0, the system will generate a Core file in the root directory of the BE deployment when the process crashes.
How to use Hints to control table join optimizer behavior?
Supportsbroadcast and shuffle Hints. For example:
select * from a join [broadcast] b on a.id = b.id;select * from a join [shuffle] b on a.id = b.id;
How to increase SQL query concurrency?
By adjusting the session variablepipeline_dop.
How to check the execution progress of DDL?
-
View all column modification tasks in the default database:
-
View the most recent column modification task for a specific table:
Why does comparing floating-point numbers sometimes result in inconsistent query results?
Directly using floating-point numbers= for comparison can lead to instability due to errors. It is recommended to use range checks.
Why does floating-point calculation result in errors?
FLOAT/DOUBLE types have precision errors inavg, sum, and other calculations, leading to potentially inconsistent query results. For high precision, use the DECIMAL type, but note that performance will decrease by 2-3 times.
Why does ORDER BY in a subquery not take effect?
In distributed execution, if ORDER BY is not specified in the outer layer of the subquery, global ordering cannot be guaranteed. This is expected behavior.Why is the result of row_number() inconsistent across multiple executions?
If the ORDER BY field has duplicates (e.g., multiple rows with the samecreateTime), SQL standards do not guarantee stable sorting. It is recommended to include a unique field (e.g., employee_id) in the ORDER BY to ensure stability.
What information is needed for SQL optimization or troubleshooting?
-
EXPLAIN COSTS <SQL>(includes statistics) -
EXPLAIN VERBOSE <SQL>(includes data types, nullable, optimization strategies) -
Query Profile (viewable through the FE Web interface at
http://<fe_ip>:<fe_http_port>and navigating to the Queries Tab) -
Query Dump (obtained via HTTP API)
- Query statement
- Table schema referenced in the query
- Session variables
- Number of BEs
- Statistics (Min, Max values)
- Exception information (exception stack)
How to check data skew?
UseADMIN SHOW REPLICA DISTRIBUTION FROM <table> to view the distribution of tablets.
How to troubleshoot memory-related errors?
There are three common scenarios:- Single query memory limit exceeded:
- Error:
Mem usage has exceed the limit of single query, You can change the limit by set session variable query_mem_limit. - Solution: Adjust
query_mem_limit
- Error:
- Query pool memory limit exceeded:
- Error:
Mem usage has exceed the limit of query pool - Solution: Optimize the SQL.
- Error:
- BE total memory limit exceeded:
- Error:
Mem usage has exceed the limit of BE - Solution: Analyze memory usage.
- Error:
What to do when encountering the error StarRocks planner use long time xxx ms in logical phase?
-
Analyze
fe.gc.logto check for Full GC occurrences. If Full GC occurs frequently, perform one of the following operations:- Allow the SQL client to access multiple frontends (FEs) simultaneously to spread the load.
- Change the heap size of Java Virtual Machine (JVM) from 8 GB to 16 GB in the fe.conf file to increase memory and reduce the impact of Full GC.
-
If the SQL execution plan is complex, increase
new_planner_optimize_timeout(unit: ms):
How to troubleshoot Unknown Error?
Try adjusting the following parameters one by one and then re-execute the SQL:What time zone does select now() return?
It returns the time zone specified by the time_zone system variable. FE/BE logs use the machine’s local time zone.
Why does SQL slow down under high concurrency even when resources are normal?
The reason is high network or RPC latency. You can adjust the BE parameterbrpc_connection_type to pooled and then restart BE.
How to disable statistics collection?
-
Disable automatic collection:
-
Disable import-triggered collection:
-
For versions upgraded to v3.3 and above, manually set: