MyISAM

my.ini的配置参数详解,以及binlog的三种模式

一曲冷凌霜 提交于 2019-12-13 15:48:35
先点赞,后观看,伸手才有好习惯 my.ini配置详解 【转载】 #*** client options 相关选项 ***# #以下选项会被MySQL客户端应用读取。注意只有MySQL附带的客户端应用程序保证可以读取这段内容。如果你想你自己的MySQL应用程序获取这些值。需要在MySQL客户端库初始化的时候指定这些选项。 [client] port = 3309 socket = /usr/local/mysql/tmp/mysql.sock [mysqld] !include /usr/local/mysql/etc/mysqld.cnf #包含的配置文件 ,把用户名,密码文件单独存放 port = 3309 bind-address = 0.0.0.0 server-id = 1 #表示是本机的序号为1,唯一 socket = /usr/local/mysql/tmp/mysql.sock pid-file = /usr/local/mysql/var/mysql.pid basedir = /usr/local/mysql/ datadir = /usr/local/mysql/var/ tmpdir = /usr/local/mysql/tmp/ #此目录被 MySQL用来保存临时文件.例如,它被用来处理基于磁盘的大型排序,和内部排序一样,以及简单的临时表

浅谈聚簇索引和非聚簇索引的区别

泪湿孤枕 提交于 2019-12-13 11:12:47
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 聚簇索引: 将数据存储与索引放到了一块,索引结构的叶子节点保存了行数据 非聚簇索引: 将数据与索引分开存储,索引结构的叶子节点指向了数据对应的位置 在innodb中 ,在聚簇索引之上创建的索引称之为辅助索引,非聚簇索引都是辅助索引,像复合索引、前缀索引、唯一索引。 辅助索引叶子节点存储的不再是行的物理位置,而是主键值,辅助索引访问数据总是需要二次查找 。 InnoDB使用的是聚簇索引,将主键组织到一棵B+树中,而行数据就储存在叶子节点上,若使用"where id = 14"这样的条件查找主键,则按照B+树的检索算法即可查找到对应的叶节点,之后获得行数据。 若对Name列进行条件搜索,则需要两个步骤:第一步在辅助索引B+树中检索Name,到达其叶子节点获取对应的主键。第二步使用主键在主索引B+树种再执行一次B+树检索操作,最终到达叶子节点即可获取整行数据。(重点在于通过其他键需要建立辅助索引) 聚簇索引具有唯一性 ,由于聚簇索引是将数据跟索引结构放到一块,因此一个表仅有一个聚簇索引。 表中行的物理顺序和索引中行的物理顺序是相同的 , 在创建任何非聚簇索引之前创建聚簇索引 ,这是因为聚簇索引改变了表中行的物理顺序,数据行 按照一定的顺序排列,并且自动维护这个顺序; 聚簇索引默认是主键 ,如果表中没有定义主键

MyISAM Performance: Join Decomposition?

﹥>﹥吖頭↗ 提交于 2019-12-13 03:49:33
问题 in High Performance MySQL on page 159 they talk about breaking up complex queries into simple ones: Converting SELECT * FROM tag JOIN tag_post ON tag_post.tag_id=tag.id JOIN post ON tag_post.post_id=post.id WHERE tag.tag='mysql'; To SELECT * FROM tag WHERE tag='mysql'; SELECT * FROM tag_post WHERE tag_id=1234; SELECT * FROM post WHERE post.id in (123,456,567,9098,8904); And sort of doing the actual join yourself in your application. My Question is wether this is stil such a good idea when the

Optimizing query to get entire row where one field is the maximum for a group

一笑奈何 提交于 2019-12-13 03:23:58
问题 I have a table with a schema like, say, EventTime DATETIME(6), EventType VARCHAR(20), Number1 INT, Number2 INT, Number3 INT, ... There are an unimaginably large number of rows in this table, but for the sake of this query I'm only interested in, say, a few thousand of them that are between two given values of EventTime . There's an index on EventTime , and if I just do something like SELECT * FROM table WHERE EventTime >= time1 and EventTime <= time2; Then it's able to return the relevant

最全MySQL面试题和答案

北慕城南 提交于 2019-12-13 02:39:00
Mysql 的存储引擎,myisam和innodb的区别。 答: 1.MyISAM 是非事务的存储引擎,适合用于频繁查询的应用。表锁,不会出现死锁,适合小数据,小并发。 2.innodb是支持事务的存储引擎,合于插入和更新操作比较多的应用,设计合理的话是行锁(最大区别就在锁的级别上),适合大数据,大并发。 数据表类型有哪些 答:MyISAM、InnoDB、HEAP、BOB,ARCHIVE,CSV等。 MyISAM:成熟、稳定、易于管理,快速读取。一些功能不支持(事务等),表级锁。 InnoDB:支持事务、外键等特性、数据行锁定。空间占用大,不支持全文索引等。 MySQL数据库作发布系统的存储,一天五万条以上的增量,预计运维三年,怎么优化? a. 设计良好的数据库结构,允许部分数据冗余,尽量避免join查询,提高效率。 b. 选择合适的表字段数据类型和存储引擎,适当的添加索引。 c. mysql库主从读写分离。 d. 找规律分表,减少单表中的数据量提高查询速度。 e。添加缓存机制,比如memcached,apc等。 f. 不经常改动的页面,生成静态页面。 g. 书写高效率的SQL。比如 SELECT * FROM TABEL 改为 SELECT field_1, field_2, field_3 FROM TABLE. 对于大流量的网站,您采用什么样的方法来解决各页面访问量统计问题?

Changing tables from MyISAM to InnoDB make the system slow

馋奶兔 提交于 2019-12-13 00:18:40
问题 Hi I am using Mysql 5.0.x I have just changed a lot of the tables from MyISAM to InnoDB With the MyISAM tables it took about 1 minute to install our database With the InnoDB it takes about 15 minute to install the same database Why does the InnoDB take so long? What can I do to speed things up? The Database install does the following steps 1) Drops the schema 2) Create the schema 3) Create tables 4) Create stored procedures 5) Insert default data 6) Insert data via stored procedure EDIT: The

Spatial Index not being used for polygon-in-bounding-box search

不羁岁月 提交于 2019-12-12 22:40:23
问题 I have a MyISAM table in MariaDB containing two datetime columns begin and end and would like to create and use a spatial index on the two in a similar fashion to the blog post here. Here is how I create the table: CREATE TABLE `mytable` ( `id` int(11) NOT NULL, `begin` datetime NOT NULL, `end` datetime NOT NULL, ) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4 After filling the table with data, I then add a polygon column: ALTER TABLE mytable add time_range_int

Mysql安装、配置、优化

Deadly 提交于 2019-12-12 13:15:05
Mysql安装、配置、优化 一: MYSQL安装和基本配置 在linux上安装,可以用包管理工具来安装,比较简单: RedHat 系列:yum -y install mysql mysql-server Debian系列:sudo apt-get install mysql mysql-server 安装之后不知道mysql装到哪了怎么办,用whereis mysql 命令来找一下。 先找到mysql的默认配置文件。一般来说,安装后有这么几个备选的配置: 1 my-huge.cnf my-innodb-heavy-4G.cnf my-large.cnf my-medium.cnf my-small.cnf  就2014年的机器配置来说,咱们直接用my-huge.cnf。把my-huge.cnf 复制到/etc/下,改名my.cnf。配置文件就有了, 然后启动mysql: /etc/init.d/mysqld start 。 安装之后默认的帐号是root, 密码为空。咱们要做的第一件事是改root密码。 进入mysql:mysql -uroot -p 选择数据库: use mysql 改密码: UPDATE user SET Password = PASSWORD(‘xxxx’) WHERE user = ‘root’; 刷新权限: FLUSH PRIVILEGES;

What do “Internal Relations” do in phpMyAdmin for MyISAM tables?

大兔子大兔子 提交于 2019-12-12 10:52:45
问题 In phpMyAdmin v2.8.2.4 for MyISAM tables, the "Relation View" appears under the Structure tab. It shows a list of Internal Relations. But what do these do, given that MyISAM does not support foreign key constraints or relational integrity? By phpMyAdmin version 3.2.0.1 this page ("Relation View") no longer appears for MyISAM tables. So does this mean that it wasn't doing anything in the first place? Any explanations much appreciated. Justin 回答1: Foreign keys in MyISAM are for advisory

Converting an existing MyISAM database to InnoDB with Django

荒凉一梦 提交于 2019-12-12 08:01:31
问题 Is there anyway I can convert a full populated MyISAM database to InnoDB (in a way that will create all foreign key contraints, same way it would be if I ran the syncdb command from the beginning)? 回答1: This might help: from django.core.management.base import BaseCommand from django.db import connections class Command(BaseCommand): def handle(self, database="default", *args, **options): cursor = connections[database].cursor() cursor.execute("SHOW TABLE STATUS") for row in cursor.fetchall():