• Mattias Jonsson's avatar
    Bug#35845: unneccesary call to ha_start_bulk_insert for not used partitions · 35d6911b
    Mattias Jonsson authored
    (Backport)
    
    Problem is that when insert (ha_start_bulk_insert) in i partitioned table,
    it will call ha_start_bulk_insert for every partition, used or not.
    
    Solution is to delay the call to the partitions ha_start_bulk_insert until
    the first row is to be inserted into that partition
    
    
    sql/ha_partition.cc:
      Bug#35845: unneccesary call to ha_start_bulk_insert for not used partitions
      
      Using a bitmap for keeping record of which partitions for which
      ha_start_bulk_insert has been called, and check against that if one
      should call it before continue with the insert/update, or if it has already
      been called.
      
      This way it will only call ha_start_bulk_insert for the used partitions.
      There is also a little prediction on how many rows that will be inserted into
      the current partition, it will guess on equal distribution of the records
      across all partitions, accept for the first used partition, which will guess
      at 50% of the given estimate, if it is a monotonic partitioning function.
    sql/ha_partition.h:
      Bug#35845: unneccesary call to ha_start_bulk_insert for not used partitions
      
      Added help variables and function for delaying ha_bulk_insert until it has
      to be called.
      
      Fixed a comment.
    35d6911b
ha_partition.h 44.7 KB