删除数据能否回收rowid?

warning: 这篇文章距离上次修改已过1629天,其中的内容可能已经有所变动。

由于shrink space时,rowid回收,如果不含索引,回收的粒度是DC,即所有被delete的DC对应的rowid都能回收。
以下是做的简单测试:
(1)gnone层总行数6001215

gbase> select count(*) from lineitem;
+----------+
| count(*) |
+----------+
|  6001215 |
+----------+
1 row in set (Elapsed: 00:00:00.14)
gbase> select min(rowid),max(rowid) from lineitem;
+------------+------------+
| min(rowid) | max(rowid) |
+------------+------------+
|          0 |    6001214 |
+------------+------------+
1 row in set (Elapsed: 00:00:00.51)

(2)删除中间1个DC的数据

gbase> delete from lineitem where rowid> 65535 and rowid <2*65536;
Query OK, 65536 rows affected (Elapsed: 00:00:00.11)
gbase> alter table lineitem shrink space;
Query OK, 0 rows affected (Elapsed: 00:00:00.07)

(3)查看rowid

gbase> select min(rowid),max(rowid) from lineitem;
+------------+------------+
| min(rowid) | max(rowid) |
+------------+------------+
|          0 |    5935678 |
+------------+------------+
1 row in set (Elapsed: 00:00:00.45)

(4)插入数据后,查看rowid

gbase> insert into lineitem(l_comment) values('hello');
Query OK, 1 row affected (Elapsed: 00:00:00.40)
gbase> select rowid from lineitem where l_comment='hello';
+---------+
| rowid   |
+---------+
| 5935679 |
+---------+
1 row in set (Elapsed: 00:00:01.60)
最后修改于:2020年11月16日 15:17

添加新评论