title: MySQL - query from slave and insert on master
body: <p>I used to run this command to insert some rows in a counter table:</p>
  
  <pre><code>insert into `monthly_aggregated_table`
  select year(r.created_at), month(r.created_at), count(r.id) from 
  raw_items r
  group by 1,2;
  </code></pre>
  
  <p>This query is very heavy and takes some time to run (millions of rows), and the <code>raw_items</code> table is MyISAM, so it was causing table locking and writes to it had to wait for the insert to finish.</p>
  
  <p>Now I created a slave server to do the <code>SELECT</code>.</p>
  
  <p>What I would like to do is to execute the <code>SELECT</code> in the slave, but get the results and insert into the master database. Is it possible? How? What is the most efficient way to do this? (The insert used to have 1.3 million rows)</p>
  
  <p>I am running MariaDB 10.0.17</p>