# README

Write Hints

Insert

go run main.go

Output:

2024/09/24 01:16:03 create table, name: 'monitor_table_with_hints'
2024/09/24 01:16:03 affected rows: 3

Query

Your can using MySQL Client to query the data from GreptimeDB.

$ mysql -h 127.0.0.1 -P 4002 public

mysql> select * from monitor_table_with_hints;
+------+-------+-------------+----------------------------+
| id   | host  | temperature | timestamp                  |
+------+-------+-------------+----------------------------+
|    1 | hello |         1.1 | 2024-09-23 17:16:03.476898 |
|    2 | hello |         2.2 | 2024-09-23 17:16:03.476898 |
|    3 | hello |         3.3 | 2024-09-23 17:16:03.476898 |
+------+-------+-------------+----------------------------+
3 rows in set (0.03 sec)

You can view hints using show create table command:

mysql> show create table monitor_table_with_hints;
+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table                  | Create Table                                                                                                                                                                                                                                                                                                      |
+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| monitor_table_with_hints | CREATE TABLE IF NOT EXISTS `monitor_table_with_hints` (
  `id` BIGINT NULL,
  `host` STRING NULL,
  `temperature` DOUBLE NULL,
  `timestamp` TIMESTAMP(6) NOT NULL,
  TIME INDEX (`timestamp`),
  PRIMARY KEY (`id`)
)

ENGINE=mito
WITH(
  append_mode = 'false',
  merge_mode = 'last_non_null',
  ttl = '3day'
) |
+------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.02 sec)