MySql - WAMP - Huge Table is very slow (20 million rows)

后端 未结 3 1699
借酒劲吻你
借酒劲吻你 2021-02-20 10:19

So I posted this! yesterday and got a perfect answer, which required running this code first: ALTER TABLE mytable AUTO_INCREMENT=10000001;

I ran it several times, but r

3条回答
  •  我在风中等你
    2021-02-20 11:12

    I believe the hardware is fine but you need to spare your resources a lot better.

    Db structure optimization!

    • Do not use TEXT!
    • For phonenumbers use bigint unsigned. Any signs or alpha must be parsed and converted.
    • For any other alpha-numeric column use eg varchar([32-256]).
    • Zip-code is of course mediumint unsigned.
    • Gender should be enum('Male','Female')
    • Sales could be an int unsigned
    • State should be enum('Alaska',...)
    • Country should be enum('Albania',...)

    When building a large index the fastest way is to create a new table and do INSERT INTO ... SELECT FROM ... rather then ALTER TABLE ....

    Changing the State and Country fields to enum will drastically reduce you indexes size.

提交回复
热议问题