Project: StarRocks (App Definition and Development / Database)
File: Sql_faq.md

displayed_sidebar: "English" This topic provides answers to some frequently asked questions about SQL. To solve this problem, increase the value of the `memorylimitationperthreadforschemachange` parameter in the be.conf file. This parameter refers to the maximum storage that can be allocated for a single task to change the scheme. The default value of the maximum storage is 2 GB. StarRocks does not directly cache final query results. From v2.5 onwards, StarRocks 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 . In standard SQL, every calculation that includes an operand with a `NULL` value returns a `NULL`. StarRocks does not support the DECODE function of the Oracle database. StarRocks is compatible with MySQL, so you can use the CASE WHEN statement. Yes. StarRocks merges data in a way that references Google Mesa. In StarRocks, 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. No. 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: ```SQL show tablet from lineitem where State="ALTER"; ``` The time spent on the alteration operation relates to the data volume. In general, the alteration can be completed in minutes. We recommend that you stop loading data into StarRocks while you are altering tables because data loading lowers the speed at which alteration completes. 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. This error occurs usually due to a full garbage collection (full GC), which can be checked by using backend monitoring and the fe.gc log. To solve this problem, perform one of the following operations: Allows SQL's 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. 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

StarRocks 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`. 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. ```plaintext MERGE: aggr: 26s270ms sort: 15s551ms ``` Nested functions are not supported, such as `todays(now())` in `DELETE from testnew WHERE todays(now())-todays(publish_time) >7;`. 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. Adjust the log level and corresponding parameters. For more information, see . When you create colocated tables, you need to set the `group` 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_with` to `empty` for all tables in a group. Set a proper `replication_num` for all tables in a group. Set `group_with` back to its original value. 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. 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, set `tabletmapshard_size` to `512` in the be.conf file to reduce the lock contention. Add the following information to hdfs-site.xml in the fe.conf file and the be.conf file: ```HTML <property> <name>dfs.namenode.kerberos.principal.pattern</name> <value>*</value> </property> ``` No. No, use functions to change "2021-10" to "2021-10-01" and then use "2021-10-01" as a partition field. You can use the command. `SHOW DATA;` displays the data size and replicas of all tables in the current database. `SHOW DATA FROM <dbname>.<tablename>;` displays the data size, number of replicas, and number of rows in a specified table of a specified database.