Insertion speed slowdown as the table grows in mysql

前端 未结 3 1763
天涯浪人
天涯浪人 2021-02-04 17:33

I am trying to get a better understanding about insertion speed and performance patterns in mysql for a custom product. I have two tables to which I keep appending new rows. The

相关标签:
3条回答
  • 2021-02-04 18:04

    Edit your /etc/mysql/my.cnf file and make sure you allocate enough memory to the InnoDB buffer pool. If this is a dedicated sever, you could probably use up to 80% of your system memory.

    # Provide a buffer pool for InnoDB - up to 80% of memory for a dedicated database server
    innodb_buffer_pool_size=614M
    

    The primary keys are B Trees so inserts will always take O(logN) time and once you run out of cache, they will start swapping like mad. When this happens, you will probably want to partition the data to keep your insertion speed up. See http://dev.mysql.com/doc/refman/5.1/en/partitioning.html for more info on partitioning.

    Good luck!

    0 讨论(0)
  • 2021-02-04 18:05

    Verifying that the insert doesn't violate a key constraint takes some time, and that time grows as the table gets larger. If you're interested in flat out performance, using LOAD DATA INFILE will improve your insert speed considerably.

    0 讨论(0)
  • 2021-02-04 18:09

    Your indexes may just need to be analyzed and optimized during the insert, they gradually get out of shape as you go along. The other option of course is to disable indexes entirely when you're inserting and rebuild them later which should give more consistent performance.

    Great link about insert speed.

    ANALYZE. OPTIMIZE

    0 讨论(0)
提交回复
热议问题