如何提高Mysql语句插入性能
在表中已有大量的index的情况下插入大量数据,可以采用先将索引删除,然后再插入数据,然后再重新建立索引。之所以这样会快是因为???
7.2.14 Speed of INSERT Statements
The time to insert a record is determined by the following factors, where the numbers indicate approximate proportions:
* Connecting: (3)
* Sending query to server: (2)
* Parsing query: (2)
* Inserting record: (1 x size of record)
* Inserting indexes: (1 x number of indexes)
* Closing: (1)
This does not take into consideration the initial overhead to open tables, which is done once for each concurrently running query.
The size of the table slows down the insertion of indexes by log N, assuming B-tree indexes.
You can use the following methods to speed up inserts:
* If you are inserting many rows from the same client at the same time, use INSERT statements with multiple VALUES lists to insert several rows at a time. This is much faster (many times faster in some cases) than using separate single-row INSERT statements. If you are adding data to a non-empty table, you may tune the bulk_insert_buffer_size variable to make it even faster. See section 5.2.3 Server System Variables.
* If you are inserting a lot of rows from different clients, you can get higher speed by using the INSERT DELAYED statement. See section 14.1.4 INSERT Syntax.
* With MyISAM tables you can insert rows at the same time that SELECT statements are running if there are no deleted rows in the tables.
* When loading a table from a text file, use LOAD DATA INFILE. This is usually 20 times faster than using a lot of INSERT statements. See section 14.1.5 LOAD DATA INFILE Syntax.
* With some extra work, it is possible to make LOAD DATA INFILE run even faster when the table has many indexes. Use the following pr
相关文档:
mysql 起动错误解决办法- -
Access denied for user ''@'localhost' to d ......
此程序实现将mysql数据库的模式信息展示出来。下面我简要地说明一下。
1.树形结构的实现。
SimplePanel pl=new SimplePanel();
private void buildFrameLayout(){
try{ pane = getContentPane();
//关闭面板
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//BorderLayout布局管理器
JPanel ......
备份MySQL数据库的命令
mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql
备份MySQL数据库为带删除表的格式
备份MySQL数据库为带删除表的格式,能够让该备份覆盖已有数据库而不需要手动删除原有数据库。
mysqldump -–add-drop-table -uusername -ppassword databasename > bac ......
1、下载MySQL的安装文件
安装MySQL需要下面两个文件:
MySQL-server-5.0.46.i386.rpm
MySQL-client-5.0.46.i386.rpm
2、安装MySQL
rpm文件是Red Hat公司开发的软件安装包,rpm可让Linux在安装软件包时免除许多复杂的手续。该命令在安装时常用的参数是
ivh
,其中i表示将安装指定的rmp软件包,V表 ......
C API相关
C API数据类型
MYSQL
该结构代表1个数据库连接的句柄。几乎所有的MySQL函数均使用它。不应尝试拷贝MYSQL结构。不保证这类拷贝结果会有用。
MYSQL_RES
该结构代表返回行的查询结果(SELECT, SHOW, DESCRIBE, EXPLAIN)。在本节的剩余部分,将查询返回的信息称为“结果集&rdq ......