mysql表空間碎片整理,mysql可以使用alter table tn engine=innodb語句進行表空間碎片整理。而頁內記錄並不是物理有序的,並且刪除記錄後,被刪除的記錄放到頁內free鍊錶,可能會產生很多空洞。alter table命令會重建表,這樣的話,猜測可能掃瞄老表頁內說有資料,乙個乙個的插入到新錶中。是不是這個過程呢?跟蹤了下堆疊:
(gdb) bt
#0 btr_cur_optimistic_insert (flags=23, cursor=0xa34a4074, offsets=0xa34a40b4, heap=0xa34a40dc, entry=0xa6b72c8,
rec=0xa34a40b8, big_rec=0xa34a40bc, n_ext=0, thr=0x0, mtr=0xa34a3c04)
at /home/mysql26/mysql-5.6.26/storage/innobase/btr/btr0cur.cc:1241
#1 0x087c006c in row_merge_insert_index_tuples (trx_id=9503, index=0xa6b7ca8, old_table=0xa4df530, fd=35,
block=0x9d232000 "\002") at /home/mysql26/mysql-5.6.26/storage/innobase/row/row0merge.cc:2519
#2 0x087c3c5e in row_merge_build_indexes (trx=0xa63a358, old_table=0xa4df530, new_table=0xa625f20, online=true,
indexes=0xa640d20, key_numbers=0xa640d28, n_indexes=1, table=0xa63fad8, add_cols=0x0, col_map=0xa640d70,
add_autoinc=4294967295, sequence=...) at /home/mysql26/mysql-5.6.26/storage/innobase/row/row0merge.cc:3743
#3 0x086f6304 in ha_innobase::inplace_alter_table (this=0xa6253b0, altered_table=0xa63fad8,
ha_alter_info=0xa34a4e7c) at /home/mysql26/mysql-5.6.26/storage/innobase/handler/handler0alter.cc:3950
#4 0x08447be2 in handler::ha_inplace_alter_table (this=0xa6253b0, altered_table=0xa63fad8,
ha_alter_info=0xa34a4e7c) at /home/mysql26/mysql-5.6.26/sql/handler.h:2870
#5 0x0844121e in mysql_inplace_alter_table (thd=0xa4e0fc0, table_list=0xa60ae48, table=0xa63e6d0,
altered_table=0xa63fad8, ha_alter_info=0xa34a4e7c, inplace_supported=ha_alter_inplace_no_lock_after_prepare,
target_mdl_request=0xa34a564c, alter_ctx=0xa34a43f4) at /home/mysql26/mysql-5.6.26/sql/sql_table.cc:6597
#6 0x08442d26 in mysql_alter_table (thd=0xa4e0fc0, new_db=0xa60b218 "yzs", new_name=0x0, create_info=0xa34a5ebc,
table_list=0xa60ae48, alter_info=0xa34a5f44, order_num=0, order=0x0, ignore=false)
at /home/mysql26/mysql-5.6.26/sql/sql_table.cc:8448
#7 0x08594a97 in sql_cmd_alter_table::execute (this=0xa60b228, thd=0xa4e0fc0)
at /home/mysql26/mysql-5.6.26/sql/sql_alter.cc:313
#8 0x083da486 in mysql_execute_command (thd=0xa4e0fc0) at /home/mysql26/mysql-5.6.26/sql/sql_parse.cc:4976
#9 0x083dae5d in mysql_parse (thd=0xa4e0fc0, rawbuf=0xa60ad98 "alter table t1 engine=innodb", length=28,
parser_state=0xa34a70e0) at /home/mysql26/mysql-5.6.26/sql/sql_parse.cc:6386
#10 0x083dc834 in dispatch_command (command=com_query, thd=0xa4e0fc0,
packet=0xa602d69 "alter table t1 engine=innodb", packet_length=28)
at /home/mysql26/mysql-5.6.26/sql/sql_parse.cc:1340
#11 0x083ddf9a in do_command (thd=0xa4e0fc0) at /home/mysql26/mysql-5.6.26/sql/sql_parse.cc:1037
#12 0x08391989 in do_handle_one_connection (thd_arg=0xa4e0fc0) at /home/mysql26/mysql-5.6.26/sql/sql_connect.cc:982
#13 0x08391a53 in handle_one_connection (arg=0xa4e0fc0) at /home/mysql26/mysql-5.6.26/sql/sql_connect.cc:898
#14 0x089b3141 in pfs_spawn_thread (arg=0xa462868) at /home/mysql26/mysql-5.6.26/storage/perfschema/pfs.cc:1860
---type to continue, or q to quit---
#15 0x00cdc832 in start_thread () from /lib/libpthread.so.0
#16 0x00c31e0e in clone () from /lib/libc.so.6mysql_execute_command->
sql_cmd_alter_table::execute ->mysql_alter_table->mysql_inplace_alter_table ->
handler::ha_inplace_alter_table ->ha_innobase::inplace_alter_table->
row_merge_build_indexes->row_merge_insert_index_tuples ->btr_cur_optimistic_insert
關鍵函式在紅色函式。
ORACLE表空間碎片整理
oracle作為一種大型資料庫,廣泛應用於金融 郵電 電力 民航等資料吞吐量巨大,計算機網路廣泛普及的重要部門。對於系統管理員來講,如何保證網路 穩定執行,如何提高資料庫效能,使其更加安全高效,就顯得尤為重要。作為影響資料庫效能的一大因素 資料庫碎片,應當引起dba的足夠重視,及時發現並 整理碎片乃...
mysql表碎片整理
1.首先檢視下表碎片資訊 其中 table schema指的是庫名,table name指的是表名,engine指的是儲存引擎,table rows指的是表裡存在行數,length指的是表和索引的總大小,data free指的是碎片大小 位元組 2.對於myisam儲存引擎使用的表,清理命令為 op...
mysql 表空間碎片 MySQL 清除表空間碎片
碎片產生的原因 1 表的儲存會出現碎片化,每當刪除了一行內容,該段空間就會變為空白 被留空,而在一段時間內的大量刪除操作,會使這種留空的空間變得比儲存列表內容所使用的空間更大 2 當執行插入操作時,mysql會嘗試使用空白空間,但如果某個空白空間一直沒有被大小合適的資料占用,仍然無法將其徹底占用,就...