#At file:///media/sda3/work/mysql/bzrwork/b35843/5.1-rpl/
2666 He Zhenxing 2008-09-09
BUG#35843 Slow replication slave when using partitioned myisam table
In order to improve the performance when replicating to partitioned
myisam tables with row-based format, a new function 'estimate_rows'
is added for Rows_log_event to estimate the number of rows of current
rows log event and use the estimated number to allocate cache memory.
modified:
sql/log_event.cc
sql/log_event.h
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc 2008-08-06 10:41:27 +0000
+++ b/sql/log_event.cc 2008-09-09 09:20:46 +0000
@@ -7439,8 +7439,28 @@ Write_rows_log_event::Write_rows_log_eve
#endif
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
+/*
+ Estimate the number of rows of current event.
+*/
+ulong
+Rows_log_event::estimate_rows(Relay_log_info const *rli)
+{
+ const uchar *curr_row_end;
+ MY_BITMAP cols;
+ int const result= ::unpack_row(rli, m_table, m_width, m_curr_row,
+ &cols, &curr_row_end, 0);
+ if (curr_row_end > m_rows_end)
+ {
+ my_error(ER_SLAVE_CORRUPT_EVENT, MYF(0));
+ return 0;
+ }
+
+ ulong rows= (m_rows_end - m_curr_row) / (curr_row_end - m_curr_row);
+ return rows;
+}
+
int
-Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability *const)
+Write_rows_log_event::do_before_row_operations(const Slave_reporting_capability *const
log)
{
int error= 0;
@@ -7488,7 +7508,10 @@ Write_rows_log_event::do_before_row_oper
*/
}
- m_table->file->ha_start_bulk_insert(0);
+ ulong rows= estimate_rows((Relay_log_info const*)log);
+ if (!rows)
+ return 1;
+ m_table->file->ha_start_bulk_insert(rows);
/*
We need TIMESTAMP_NO_AUTO_SET otherwise ha_write_row() will not use fill
any TIMESTAMP column with data from the row but instead will use
=== modified file 'sql/log_event.h'
--- a/sql/log_event.h 2008-07-31 06:24:27 +0000
+++ b/sql/log_event.h 2008-09-09 09:20:46 +0000
@@ -3428,6 +3428,16 @@ public:
uint m_row_count; /* The number of rows added to the event */
+ /**
+ Estimate number of rows included in this Rows_log_event.
+
+ @param rli Relay log info structure
+
+ @retval >0 the number of rows in the event
+ @retval 0 the event is corrupted
+ */
+ ulong estimate_rows(Relay_log_info const *rli);
+
protected:
/*
The constructors are protected since you're supposed to inherit