title: Mariadb configurations for optimal performance
body: <p>We have a table in mariadb with large number of row like 3 million. This table is been indexed . We have job which inserts 3 million records to this table. Query on this table takes more than a minute. Observation is query is fast after sometime the data is been inserted (say after 30 minutes).
  Our observation is table indexing is taking time and once the indexing is done queries are executed quickly.
  Sample query is like</p>
  
  <pre><code>select count(distinct userd_id) from users;
  </code></pre>
  
  <p>Where user_id column is indexed. Below is the explain on the query</p>
  
  <pre><code>   +------+-------------+---------------------------+-------+---------------+-------------------------+---------+------+---------+------------------------------+
  | id   | select_type | table                     | type  | possible_keys | key                     | key_len | ref  | rows    | Extra                        |
  +------+-------------+---------------------------+-------+---------------+-------------------------+---------+------+---------+------------------------------+
  |    1 | SIMPLE      | users                     | index | NULL          | index_on_user_id | 13      | NULL | 3505169 | Using index; Using temporary |
  +------+-------------+---------------------------+-------+---------------+-------------------------+---------+------+---------+------------------------------+
  </code></pre>
  
  <p>What are the best configuration we can do to reduce the query execution time. 
  System has 8 cores and 32 GB RAM and device has 500GB storage.</p>