SQL Frequently Asked Questions

Other

What is sql_mode in MatrixOne?

MatrixOne’s default sql_mode is only_full_group_by in MySQL. So all select fields in the default query syntax, except those in the aggregate function, must appear in group by . But MatrixOne also supports modifying sql_mode to be compatible with the incomplete specification of group by syntax.

show tables in MatrixOne cannot view temporary tables, how can I see if it was created successfully?

Currently it can be viewed through the “show create table temporary table name” . Since temporary tables are only visible in the current session after they are created, at the end of the current session the database automatically deletes the temporary table and frees up all space, which is usually human-aware during its lifetime.

How do I view my Query execution plan?

To see how MatrixOne executes on a given query, you can use the EXPLAIN statement, which prints out the query plan.

EXPLAIN SELECT col1 FROM tbl1; 

How to check the table compression ratio?

To check the table compression ratio in MatrixOne, you can use the following SQL query:

mysql> select ( sum(compress_size) + 1) / ( sum(origin_size) +1 ) from metadata_scan('db1.students', '*') m;
+---------------------------------------------------+
| (sum(compress_size) + 1) / (sum(origin_size) + 1) |
+---------------------------------------------------+
|                               0.44582681643679795 |
+---------------------------------------------------+
1 row in set (0.01 sec)

The compression ratio of the students table is approximately: 1 - 44.96% = 55.04%.

NOTE: During the data compression process, if the data has not yet been written from memory to disk, the compression ratio obtained from the query may not be accurate. Typically, data will be written to disk within 5 minutes, so it is recommended to wait until the data is flushed to disk before performing the query.