1 diff -r 936d427a9a15 innobase/btr/btr0cur.c
2 --- a/innobase/btr/btr0cur.c Mon Dec 22 00:33:03 2008 -0800
3 +++ b/innobase/btr/btr0cur.c Mon Dec 22 00:33:11 2008 -0800
5 == index->table->comp);
9 + /* Initializes status counters */
10 + innobase_mysql_thd_init_innodb_scan_cont();
11 + innobase_mysql_thd_init_innodb_scan_jump();
12 + innobase_mysql_thd_init_innodb_scan_data();
13 + innobase_mysql_thd_init_innodb_scan_garbage();
20 btr_cur_add_path_info(cursor, height,
24 + /* Initializes status counters */
25 + innobase_mysql_thd_init_innodb_scan_cont();
26 + innobase_mysql_thd_init_innodb_scan_jump();
27 + innobase_mysql_thd_init_innodb_scan_data();
28 + innobase_mysql_thd_init_innodb_scan_garbage();
32 diff -r 936d427a9a15 innobase/btr/btr0pcur.c
33 --- a/innobase/btr/btr0pcur.c Mon Dec 22 00:33:03 2008 -0800
34 +++ b/innobase/btr/btr0pcur.c Mon Dec 22 00:33:11 2008 -0800
36 last record of the current page */
37 mtr_t* mtr) /* in: mtr */
44 cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
46 page = btr_pcur_get_page(cursor);
47 + page_no = buf_frame_get_page_no(page);
49 next_page_no = btr_page_get_next(page, mtr);
50 space = buf_frame_get_space_id(page);
52 ut_ad(next_page_no != FIL_NULL);
54 + if (next_page_no - page_no == 1) {
55 + innobase_mysql_thd_increment_innodb_scan_cont(1);
57 + innobase_mysql_thd_increment_innodb_scan_jump(1);
59 + innobase_mysql_thd_increment_innodb_scan_data(
60 + page_get_data_size(page));
61 + innobase_mysql_thd_increment_innodb_scan_garbage(
62 + page_header_get_field(page, PAGE_GARBAGE));
64 next_page = btr_page_get(space, next_page_no, cursor->latch_mode, mtr);
65 ut_a(page_is_comp(next_page) == page_is_comp(page));
67 record of the current page */
68 mtr_t* mtr) /* in: mtr */
75 btr_pcur_restore_position(latch_mode2, cursor, mtr);
77 page = btr_pcur_get_page(cursor);
78 + page_no = buf_frame_get_page_no(page);
80 prev_page_no = btr_page_get_prev(page, mtr);
81 space = buf_frame_get_space_id(page);
83 + if (page_no - prev_page_no == 1) {
84 + innobase_mysql_thd_increment_innodb_scan_cont(1);
86 + innobase_mysql_thd_increment_innodb_scan_jump(1);
88 + innobase_mysql_thd_increment_innodb_scan_data(
89 + page_get_data_size(page));
90 + innobase_mysql_thd_increment_innodb_scan_garbage(
91 + page_header_get_field(page, PAGE_GARBAGE));
93 if (btr_pcur_is_before_first_on_page(cursor, mtr)
94 && (prev_page_no != FIL_NULL)) {
95 diff -r 936d427a9a15 innobase/btr/btr0sea.c
96 --- a/innobase/btr/btr0sea.c Mon Dec 22 00:33:03 2008 -0800
97 +++ b/innobase/btr/btr0sea.c Mon Dec 22 00:33:11 2008 -0800
100 buf_pool->n_page_gets++;
102 + /* Initializes status counters */
103 + innobase_mysql_thd_init_innodb_scan_cont();
104 + innobase_mysql_thd_init_innodb_scan_jump();
105 + innobase_mysql_thd_init_innodb_scan_data();
106 + innobase_mysql_thd_init_innodb_scan_garbage();
110 /*-------------------------------------------*/
111 diff -r 936d427a9a15 innobase/include/btr0cur.h
112 --- a/innobase/include/btr0cur.h Mon Dec 22 00:33:03 2008 -0800
113 +++ b/innobase/include/btr0cur.h Mon Dec 22 00:33:11 2008 -0800
115 extern ulint btr_cur_n_non_sea_old;
116 extern ulint btr_cur_n_sea_old;
118 +/*--------------------------------------*/
119 +/* prototypes for new functions added to ha_innodb.cc */
120 +void innobase_mysql_thd_init_innodb_scan_cont();
121 +void innobase_mysql_thd_increment_innodb_scan_cont(ulong length);
122 +void innobase_mysql_thd_init_innodb_scan_jump();
123 +void innobase_mysql_thd_increment_innodb_scan_jump(ulong length);
124 +void innobase_mysql_thd_init_innodb_scan_data();
125 +void innobase_mysql_thd_increment_innodb_scan_data(ulong length);
126 +void innobase_mysql_thd_init_innodb_scan_garbage();
127 +void innobase_mysql_thd_increment_innodb_scan_garbage(ulong length);
130 #include "btr0cur.ic"
132 diff -r 936d427a9a15 patch_info/innodb_check_fragmentation.info
133 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
134 +++ b/patch_info/innodb_check_fragmentation.info Mon Dec 22 00:33:11 2008 -0800
136 +File=innodb_check_fragmentation.patch
137 +Name=Session status to check fragmentation of the last InnoDB scan
139 +Author=Percona <info@percona.com>
141 +Comment=The names are Innodb_scan_*
142 diff -r 936d427a9a15 sql/ha_innodb.cc
143 --- a/sql/ha_innodb.cc Mon Dec 22 00:33:03 2008 -0800
144 +++ b/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
145 @@ -760,6 +760,102 @@
148 /*************************************************************************
149 +Initializes Innodb_scan_blocks_contiguous. */
152 +innobase_mysql_thd_init_innodb_scan_cont()
154 + THD *thd=current_thd;
155 + if (likely(thd != 0)) {
156 + thd->status_var.innodb_scan_cont = 0;
160 +/*************************************************************************
161 +Increments Innodb_scan_blocks_contiguous. */
164 +innobase_mysql_thd_increment_innodb_scan_cont(ulong length)
166 + THD *thd=current_thd;
167 + if (likely(thd != 0)) {
168 + thd->status_var.innodb_scan_cont+= length;
172 +/*************************************************************************
173 +Initializes Innodb_scan_blocks_jumpy. */
176 +innobase_mysql_thd_init_innodb_scan_jump()
178 + THD *thd=current_thd;
179 + if (likely(thd != 0)) {
180 + thd->status_var.innodb_scan_jump = 0;
184 +/*************************************************************************
185 +Increments Innodb_scan_blocks_jumpy. */
188 +innobase_mysql_thd_increment_innodb_scan_jump(ulong length)
190 + THD *thd=current_thd;
191 + if (likely(thd != 0)) {
192 + thd->status_var.innodb_scan_jump+= length;
196 +/*************************************************************************
197 +Initializes Innodb_scan_data_in_pages. */
200 +innobase_mysql_thd_init_innodb_scan_data()
202 + THD *thd=current_thd;
203 + if (likely(thd != 0)) {
204 + thd->status_var.innodb_scan_data = 0;
208 +/*************************************************************************
209 +Increments Innodb_scan_data_in_pages. */
212 +innobase_mysql_thd_increment_innodb_scan_data(ulong length)
214 + THD *thd=current_thd;
215 + if (likely(thd != 0)) {
216 + thd->status_var.innodb_scan_data+= length;
220 +/*************************************************************************
221 +Initializes Innodb_scan_garbages_in_pages. */
224 +innobase_mysql_thd_init_innodb_scan_garbage()
226 + THD *thd=current_thd;
227 + if (likely(thd != 0)) {
228 + thd->status_var.innodb_scan_garbage = 0;
232 +/*************************************************************************
233 +Increments Innodb_scan_garbages_in_pages. */
236 +innobase_mysql_thd_increment_innodb_scan_garbage(ulong length)
238 + THD *thd=current_thd;
239 + if (likely(thd != 0)) {
240 + thd->status_var.innodb_scan_garbage+= length;
244 +/*************************************************************************
245 Gets the InnoDB transaction handle for a MySQL handler object, creates
246 an InnoDB transaction struct if the corresponding MySQL thread struct still
248 diff -r 936d427a9a15 sql/mysqld.cc
249 --- a/sql/mysqld.cc Mon Dec 22 00:33:03 2008 -0800
250 +++ b/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
251 @@ -6673,6 +6673,10 @@
252 {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS},
253 #ifdef HAVE_INNOBASE_DB
254 {"Innodb_", (char*) &innodb_status_variables, SHOW_VARS},
255 + {"Innodb_scan_pages_contiguous",(char*) offsetof(STATUS_VAR, innodb_scan_cont), SHOW_LONGLONG_STATUS},
256 + {"Innodb_scan_pages_jumpy", (char*) offsetof(STATUS_VAR, innodb_scan_jump), SHOW_LONGLONG_STATUS},
257 + {"Innodb_scan_data_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_data), SHOW_LONGLONG_STATUS},
258 + {"Innodb_scan_garbages_in_pages",(char*) offsetof(STATUS_VAR, innodb_scan_garbage), SHOW_LONGLONG_STATUS},
259 #endif /*HAVE_INNOBASE_DB*/
260 {"Key_blocks_not_flushed", (char*) &dflt_key_cache_var.global_blocks_changed, SHOW_KEY_CACHE_LONG},
261 {"Key_blocks_unused", (char*) &dflt_key_cache_var.blocks_unused, SHOW_KEY_CACHE_CONST_LONG},
262 diff -r 936d427a9a15 sql/sql_class.h
263 --- a/sql/sql_class.h Mon Dec 22 00:33:03 2008 -0800
264 +++ b/sql/sql_class.h Mon Dec 22 00:33:11 2008 -0800
266 sense to add to the /global/ status variable counter.
268 double last_query_cost;
269 + ulonglong innodb_scan_cont;
270 + ulonglong innodb_scan_jump;
271 + ulonglong innodb_scan_data;
272 + ulonglong innodb_scan_garbage;