Ways to add indexes to large tables in MySQL

Source: Internet
Author: User

The difference between a hash index and a btree index
Http://database.51cto.com/art/201010/229525.htm

Creating indexes/sorting on very large tables in Mysql
http://li.angshan.blog.163.com/blog/static/131332289201203053128110/

MySQL load Data infile-acceleration?
Http://stackoverflow.com/questions/2463602/mysql-load-data-infile-acceleration


LOAD DATA infile–performance Case Study
http://venublog.com/2007/11/07/load-data-infile-performance/

First, enter the console
mysql-uroot-pdsideal4r5t6y7u


Second, backup
SELECT * from T_resource_base to outfile '/tmp/t_resource_base.txt ' fields terminated by ', ' enclosed by ' ";


Splitting files in Linux
Mkdir/usr/local/prefix-p
Reference: http://www.nowamagic.net/librarys/veda/detail/2495

Split-a 2-d-L 50000/tmp/t_resource_base.txt/usr/local/prefix


Third, delete the index or create an index
CREATE INDEX index_name on table_name (column_list)

DROP INDEX index_name on Talbe_name

Iv., perform the import (Load data infile)
Optimizing MySQL Parameters: http://www.jb51.net/article/47419.htm


MYSQL Bulk Data Loading for InnoDB Tables
Http://dev.mysql.com/doc/refman/5.5/en/optimizing-innodb-bulk-data-loading.html


SET autocommit=0;
SET unique_checks=0;
SET foreign_key_checks=0;
Set sql_log_bin=0;

SET @innodb_additional_mem_pool_size = 26214400;
Set @innodb_buffer_pool_size = 1073741824;
Set @innodb_log_buffer_size = 8388608;
Set @innodb_log_file_size = 268435456;

Five
MySQL > Use dsideal_db;
MySQL > TRUNCATE table t_resource_base;


Six
Load data infile '/usr/local/prefix00 ' IGNORE into table dsideal_db.t_resource_base fields terminated by ', ' enclosed by ' "‘;
Load data infile '/usr/local/prefix01 ' IGNORE into table dsideal_db.t_resource_base fields terminated by ', ' enclosed by ' "‘;
Load data infile '/usr/local/prefix02 ' IGNORE into table dsideal_db.t_resource_base fields terminated by ', ' enclosed by ' "‘;
Load data infile '/usr/local/prefix03 ' IGNORE into table dsideal_db.t_resource_base fields terminated by ', ' enclosed by ' "‘;
Load data infile '/usr/local/prefix04 ' IGNORE into table dsideal_db.t_resource_base fields terminated by ', ' enclosed by ' "‘;
Load data infile '/usr/local/prefix05 ' IGNORE into table dsideal_db.t_resource_base fields terminated by ', ' enclosed by ' "‘;

MySQL > commit;

Vii. resumption of the scene
SET autocommit=1;
SET Unique_checks=1;
SET Foreign_key_checks=1;
Set sql_log_bin=1;

=============================================================================================================== ==========

Ways to add indexes to large tables in MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.