]> git.pld-linux.org Git - packages/mysql.git/blob - mysql-innodb_check_fragmentation.patch
- expire-logs-days sample
[packages/mysql.git] / mysql-innodb_check_fragmentation.patch
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
4 @@ -516,6 +516,14 @@
5                                                 == index->table->comp);
6                         }
7  
8 +                       if (level == 0) {
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();
14 +                       }
15 +
16                         break;
17                 }
18  
19 @@ -663,6 +671,12 @@
20                                 btr_cur_add_path_info(cursor, height,
21                                                       root_height);
22                         }
23 +
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();
29  
30                         break;
31                 }
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
35 @@ -381,6 +381,7 @@
36                                 last record of the current page */
37         mtr_t*          mtr)    /* in: mtr */
38  {
39 +       ulint   page_no;
40         ulint   next_page_no;
41         ulint   space;
42         page_t* page;
43 @@ -393,11 +394,22 @@
44         cursor->old_stored = BTR_PCUR_OLD_NOT_STORED;
45         
46         page = btr_pcur_get_page(cursor);
47 +       page_no = buf_frame_get_page_no(page);
48  
49         next_page_no = btr_page_get_next(page, mtr);
50         space = buf_frame_get_space_id(page);
51  
52         ut_ad(next_page_no != FIL_NULL);        
53 +
54 +       if (next_page_no - page_no == 1) {
55 +               innobase_mysql_thd_increment_innodb_scan_cont(1);
56 +       } else {
57 +               innobase_mysql_thd_increment_innodb_scan_jump(1);
58 +       }
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));
63  
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));
66 @@ -427,6 +439,7 @@
67                                 record of the current page */
68         mtr_t*          mtr)    /* in: mtr */
69  {
70 +       ulint   page_no;
71         ulint   prev_page_no;
72         ulint   space;
73         page_t* page;
74 @@ -462,9 +475,20 @@
75         btr_pcur_restore_position(latch_mode2, cursor, mtr);    
76  
77         page = btr_pcur_get_page(cursor);
78 +       page_no = buf_frame_get_page_no(page);
79  
80         prev_page_no = btr_page_get_prev(page, mtr);
81         space = buf_frame_get_space_id(page);
82 +
83 +       if (page_no - prev_page_no == 1) {
84 +               innobase_mysql_thd_increment_innodb_scan_cont(1);
85 +       } else {
86 +               innobase_mysql_thd_increment_innodb_scan_jump(1);
87 +       }
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));
92  
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
98 @@ -861,6 +861,12 @@
99  
100         buf_pool->n_page_gets++;
101  
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();
107 +
108         return(TRUE);   
109  
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
114 @@ -697,6 +697,17 @@
115  extern ulint   btr_cur_n_non_sea_old;
116  extern ulint   btr_cur_n_sea_old;
117  
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);
128 +
129  #ifndef UNIV_NONINL
130  #include "btr0cur.ic"
131  #endif
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
135 @@ -0,0 +1,6 @@
136 +File=innodb_check_fragmentation.patch
137 +Name=Session status to check fragmentation of the last InnoDB scan
138 +Version=1.0
139 +Author=Percona <info@percona.com>
140 +License=GPL
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 @@
146  }
147  
148  /*************************************************************************
149 +Initializes Innodb_scan_blocks_contiguous. */
150 +extern "C"
151 +void
152 +innobase_mysql_thd_init_innodb_scan_cont()
153 +{
154 +       THD *thd=current_thd;
155 +       if (likely(thd != 0)) {
156 +               thd->status_var.innodb_scan_cont = 0;
157 +       }
158 +}
159 +
160 +/*************************************************************************
161 +Increments Innodb_scan_blocks_contiguous. */
162 +extern "C"
163 +void
164 +innobase_mysql_thd_increment_innodb_scan_cont(ulong length)
165 +{
166 +       THD *thd=current_thd;
167 +       if (likely(thd != 0)) {
168 +               thd->status_var.innodb_scan_cont+= length;
169 +       }
170 +}
171 +
172 +/*************************************************************************
173 +Initializes Innodb_scan_blocks_jumpy. */
174 +extern "C"
175 +void
176 +innobase_mysql_thd_init_innodb_scan_jump()
177 +{
178 +       THD *thd=current_thd;
179 +       if (likely(thd != 0)) {
180 +               thd->status_var.innodb_scan_jump = 0;
181 +       }
182 +}
183 +
184 +/*************************************************************************
185 +Increments Innodb_scan_blocks_jumpy. */
186 +extern "C"
187 +void
188 +innobase_mysql_thd_increment_innodb_scan_jump(ulong length)
189 +{
190 +       THD *thd=current_thd;
191 +       if (likely(thd != 0)) {
192 +               thd->status_var.innodb_scan_jump+= length;
193 +       }
194 +}
195 +
196 +/*************************************************************************
197 +Initializes Innodb_scan_data_in_pages. */
198 +extern "C"
199 +void
200 +innobase_mysql_thd_init_innodb_scan_data()
201 +{
202 +       THD *thd=current_thd;
203 +       if (likely(thd != 0)) {
204 +               thd->status_var.innodb_scan_data = 0;
205 +       }
206 +}
207 +
208 +/*************************************************************************
209 +Increments Innodb_scan_data_in_pages. */
210 +extern "C"
211 +void
212 +innobase_mysql_thd_increment_innodb_scan_data(ulong length)
213 +{
214 +       THD *thd=current_thd;
215 +       if (likely(thd != 0)) {
216 +               thd->status_var.innodb_scan_data+= length;
217 +       }
218 +}
219 +
220 +/*************************************************************************
221 +Initializes Innodb_scan_garbages_in_pages. */
222 +extern "C"
223 +void
224 +innobase_mysql_thd_init_innodb_scan_garbage()
225 +{
226 +       THD *thd=current_thd;
227 +       if (likely(thd != 0)) {
228 +               thd->status_var.innodb_scan_garbage = 0;
229 +       }
230 +}
231 +
232 +/*************************************************************************
233 +Increments Innodb_scan_garbages_in_pages. */
234 +extern "C"
235 +void
236 +innobase_mysql_thd_increment_innodb_scan_garbage(ulong length)
237 +{
238 +       THD *thd=current_thd;
239 +       if (likely(thd != 0)) {
240 +               thd->status_var.innodb_scan_garbage+= length;
241 +       }
242 +}
243 +
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
247  lacks one. */
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
265 @@ -729,6 +729,10 @@
266      sense to add to the /global/ status variable counter.
267    */
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;
273  } STATUS_VAR;
274  
275  /*
This page took 0.185763 seconds and 3 git commands to generate.