MyISAM

Fulltext Indexing on MyISAM, single column vs multiple column indexing

馋奶兔 提交于 2019-12-02 18:48:19
问题 I have an extremely large table (4M+ rows) with disk space of more than 40Gb (14Gb data and 28Gb index). I needed fulltext search on multiple fields both combined and separated, meaning that I needed to make it possible to fulltext search on both single columns and multiple columns together, like below: for combined search SELECT `column_a`, `column_b` FROM `table_1` WHERE MATCH (`column_a`, `column_c`, `column_x`) AGAINST ('+$search_quesry*' IN BOOLEAN MODE); for separate search SELECT

How to test an SQL Update statement before running it?

蹲街弑〆低调 提交于 2019-12-02 17:22:23
In some cases, running an UPDATE statement in production can save the day. However a borked update can be worse than the initial problem. Short of using a test database, what are options to tell what an update statement will do before running it? In addition to using a transaction as Imad has said (which should be mandatory anyway) you can also do a sanity check which rows are affected by running a select using the same WHERE clause as the UPDATE. So if you UPDATE is UPDATE foo SET bar = 42 WHERE col1 = 1 AND col2 = 'foobar'; The following will show you which rows will be updated: SELECT *

InnoDB performance tweaks

二次信任 提交于 2019-12-02 16:52:30
I'm switching a large table to InnoDB from myISAM. There has been a lot of discussion regarding why switching makes sense, but not much about HOW to do it while making sure the table performs well. Assuming I'll have InnoDB and MyISAM tables in on database, are there parameters I should change in the MySQL conf file to facilitate better performance? Any other defaults that can be bumped up to tweak performance? Your innodb_buffer_pool_size should be set to the amount of InnoDB data and indexes you have. Run this query and it will tell you the Minimum recommended setting for mysql's current

Can InnoDB use a stopword file?

浪子不回头ぞ 提交于 2019-12-02 14:55:06
问题 With fulltext search for MyISAM, I know that I can specify a stopword file in my.cnf with the following: ft_stopword_file = '/etc/stopword.txt' Can the same also be done with fulltext search for InnoDB? I'd like to do something like the following if possible: ft_stopword_file_innodb = '/etc/stopword.txt' However, I haven't seen any documentation indicating that stopwords for InnoDB can be stored in a file. 回答1: No, it cannot natively, hotwired, use a text file out of the box. That is, mysql

PDO fetch returns only first row [duplicate]

妖精的绣舞 提交于 2019-12-02 14:39:57
This question is an exact duplicate of: PHP PDO Data_length always returns “0” 1 answer UPDATE 2: I kindly asked to unmark this question as duplicate as it is not a duplicate of the other question, which after some research I discovered the problem and provided an effective answer, which the person that marked my question as duplicate didn't provide stating that the code worked for him. Well, it is working for him, but it is not working for me. I also read many many questions where when someone tests the code and it works for him, he just puts a note in the comments like this " It works for me

Fulltext Indexing on MyISAM, single column vs multiple column indexing

旧巷老猫 提交于 2019-12-02 12:04:05
I have an extremely large table (4M+ rows) with disk space of more than 40Gb (14Gb data and 28Gb index). I needed fulltext search on multiple fields both combined and separated, meaning that I needed to make it possible to fulltext search on both single columns and multiple columns together, like below: for combined search SELECT `column_a`, `column_b` FROM `table_1` WHERE MATCH (`column_a`, `column_c`, `column_x`) AGAINST ('+$search_quesry*' IN BOOLEAN MODE); for separate search SELECT `column_a`, `column_b` FROM `table_1` WHERE MATCH (`column_a`) AGAINST ('+search_query*' IN BOOLEAN MODE);

MyISAM与InnoDB的索引差异

扶醉桌前 提交于 2019-12-02 11:22:04
MyISAM与InnoDB的索引差异 数据库的索引分为主键索引(Primary Inkex)与普通索引(Secondary Index) 一、MyISAM的索引 MyISAM的索引与行记录是分开存储的,叫做非聚集索引(UnClustered Index)。 其主键索引与普通索引没有本质差异: 有连续聚集的区域单独存储行记录 主键索引的叶子节点,存储主键,与对应行记录的指针 普通索引的叶子结点,存储索引列,与对应行记录的指针 MyISAM的表可以没有主键。 主键索引与普通索引是两棵独立的索引B+树,通过索引列查找时,先定位到B+树的叶子节点,再通过指针定位到行记录。 举个例子,MyISAM: t ( id PK , name KEY , sex , flag ) ; 表中有四条记录: 1 , shenjian , m , A 3 , zhangsan , m , A 5 , lisi , m , A 9 , wangwu , f , B 其B+树索引构造如上图: 行记录单独存储 id为PK,有一棵id的索引树,叶子指向行记录 name为KEY,有一棵name的索引树,叶子也指向行记录 二、InnoDB的索引 InnoDB的主键索引与行记录是存储在一起的,故叫做聚集索引(Clustered Index): 没有单独区域存储行记录 主键索引的叶子节点,存储主键,与对应行记录(而不是指针)

加速MySQL的alter table操作

 ̄綄美尐妖づ 提交于 2019-12-02 10:38:54
MySQL的alter table性能在表很大的时候会出现问题。MySQL执行大部分更改操作都是新建一个需要的结构的空表,然后把所有老的数据插入到新表,最后删除旧表。这会耗费很多时间,尤其是在内存紧张,而表很大并有很多索引的时候。 不是所有的alter table操作都会导致重建表。例如,可以通过两种方式创建或去掉列的默认值(一种快、一种慢)。下面是较慢的方式: alter table film modify column rental_duration tinyint(3) not null default 5; 使用show status分析该命令发现,它执行了1001次句柄读取和1000次写入。换句话说,即使列类型、大小和可空性没有变化,它也把表拷贝到了新表中。 flush status; alter table film modify column rental_duration tinyint(3) not null default 5; show session status like 'handle%'; Variable_name Value Handler_commit 2 ...... Handler_read_rnd_next 1001 ...... Handler_write 1000 理论上,MySQL能跳过构建一个新表的方式。列的默认值实际保存在表的

Can InnoDB use a stopword file?

烂漫一生 提交于 2019-12-02 08:30:29
With fulltext search for MyISAM, I know that I can specify a stopword file in my.cnf with the following: ft_stopword_file = '/etc/stopword.txt' Can the same also be done with fulltext search for InnoDB? I'd like to do something like the following if possible: ft_stopword_file_innodb = '/etc/stopword.txt' However, I haven't seen any documentation indicating that stopwords for InnoDB can be stored in a file. No, it cannot natively, hotwired, use a text file out of the box. That is, mysql as shipped. To achieve that you would need to write speciality UDF's which would be absurd considering the

Linux知识点整理

♀尐吖头ヾ 提交于 2019-12-02 08:10:01
Linux常见的分区模式 : mbr 1-4个主分区,2.2TB,命令:fdisk gpt 多个主分区,18EB,命令: parted swap 虚拟内存 :当系统的物理内存不够用的时候,就需要将物理内存中的一部分空间释放出来,以供当前运行的程序使用。那些被释放的空间可能来自一些很长时间没有什么操作的程序,这些被释放的空间被临时保存到Swap空间中,等到那些程序要运行时,再从Swap中恢复保存的数据到内存中. ssh免密登录 端口号:22 ssh-keygen 生成密钥对 ssh-copy-id 发送公钥 raid磁盘阵列 raid0:条带模式,至少2块磁盘,通过并发提高读写效率 raid1:镜像模式,至少2块磁盘,通过镜像备份提高磁盘的可靠性 raid10:条带+镜像,至少4块磁盘,提高读写效率和可靠性 raid5:高性价比模式,至少3块磁盘,1块存放恢复效验数据 raid6:相当于扩展版raid5,至少4块磁盘,2块存放效验数据 nfs :网络文件系统 2049 包:nfs-utils ,(rpcbind)作为依赖安装 NFS服务依赖于RPC(Remote Procedure Call)服务。nfsd默认端口2049,实际使用过程中因为需要提供不同的服务,因此NFS启动时还会随机调用系统的空闲端口。在centos5.x中默认调用1024以下端口,centos6