MyISAM

Speed-up of readonly MyISAM table

我怕爱的太早我们不能终老 提交于 2020-01-01 06:36:05
问题 We have a large MyISAM table that is used to archive old data. This archiving is performed every month, and except from these occasions data is never written to the table. Is there anyway to "tell" MySQL that this table is read-only, so that MySQL might optimize the performance of reads from this table? I've looked at the MEMORY storage engine, but the problem is that this table is so large that it would take a large portion of the servers memory, which I don't want. Hope my question is clear

MYSQL数据库引擎区别详解

风流意气都作罢 提交于 2020-01-01 05:29:41
数据库引擎介绍 MySQL数据库引擎取决于MySQL在安装的时候是如何被编译的。要添加一个新的引擎,就必须重新编译MYSQL。在缺省情况下,MYSQL支持三个引擎:ISAM、MYISAM和HEAP。另外两种类型INNODB和BERKLEY(BDB),也常常可以使用。如果技术高超,还可以使用MySQL+API自己做一个引擎。下面介绍几种数据库引擎: ISAM :ISAM是一个定义明确且历经时间考验的数据表格管理方法,它在设计之时就考虑到 数据库被查询的次数要远大于更新的次数。因此,ISAM执行读取操作的速度很快,而且不占用大量的内存和存储资源。ISAM的两个主要不足之处在于,它不 支持事务处理,也不能够容错:如果你的硬盘崩溃了,那么数据文件就无法恢复了。如果你正在把ISAM用在关键任务应用程序里,那就必须经常备份你所有的实 时数据,通过其复制特性,MYSQL能够支持这样的备份应用程序。 MyISAM :MyISAM是MySQL的ISAM扩展格式和缺省的数据库引擎。除了提供ISAM里所没有的索引和字段管理的大量功能,MyISAM还使用一种表格锁定的机制,来优化多个并发的读写操作,其代价是你需要经常运行OPTIMIZE TABLE命令,来恢复被更新机制所浪费的空间。MyISAM还有一些有用的扩展,例如用来修复数据库文件的MyISAMCHK工具和用来恢复浪费空间的 MyISAMPACK工具

mysql 索引

空扰寡人 提交于 2020-01-01 04:22:40
一、索引的种类 1.单列索引:一个索引只包含单个列,但一个表中可以有多个单列索引。 这里不要搞混淆了。   普通索引:MySQL中基本索引类型,没有什么限制,允许在定义索引的列中插入重复值和空值,纯粹为了查询数据更快一点。   唯一索引:索引列中的值必须是唯一的,但是允许为空值,   主键索引:是一种特殊的唯一索引,不允许有空值。 2.组合索引:在表中的多个字段组合上创建的索引,只有在查询条件中使用了这些字段的左边字段时,索引才会被使用,使用组合索引时遵循最左前缀集合。 3.全文索引:全文索引,只有在MyISAM引擎上才能使用,只能在CHAR,VARCHAR,TEXT类型字段上使用全文索引。 (5.6.4以后InnoDB也可以使用全文索引) 二、索引的curd 1.索引的创建 ALTER TABLE 适用于表创建完毕之后再添加 ALTER TABLE 表名 ADD 索引类型 (unique,primary key,fulltext,index)[索引名](字段名) ALTER TABLE `table_name` ADD INDEX `index_name` (`column_list`) -- 索引名,可要可不要;如果不要,当前的索引名就是该字段名; ALTER TABLE `table_name` ADD UNIQUE (`column_list`) ALTER TABLE

hibernate中dialect的讲解

*爱你&永不变心* 提交于 2019-12-31 07:45:40
RDBMS方言 DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect DB2 OS390 org.hibernate.dialect.DB2390Dialect PostgreSQL org.hibernate.dialect.PostgreSQLDialect MySQL org.hibernate.dialect.MySQLDialect MySQL with InnoDB org.hibernate.dialect.MySQLInnoDBDialect MySQL with MyISAM org.hibernate.dialect.MySQLMyISAMDialect Oracle (any version) org.hibernate.dialect.OracleDialect Oracle 9i/10g org.hibernate.dialect.Oracle9Dialect Sybase org.hibernate.dialect.SybaseDialect Sybase Anywhere org.hibernate.dialect.SybaseAnywhereDialect Microsoft SQL Server org.hibernate

MySQL Atomic UPDATE in InnoDB vs MyISAM

痴心易碎 提交于 2019-12-30 19:27:10
问题 Is this "compare and swap" statement always atomic regardless of engine (e.g. InnoDB or MyISAM)? : UPDATE tbl_name SET locked=1 WHERE id=ID AND locked <> 1; I ask this because I intend to use this statement to do pseudo row-level locking that is compatible with both transactional and non-transactional database tables. This is the method that is recommended for MyISAM, but I am uncertain as to whether this works for InnoDB since the documentation suggests using transactions instead. 回答1: Yes.

新特性解读 | MySQL 8.0 Temptable 引擎介绍

自作多情 提交于 2019-12-30 13:50:51
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 原创作者: 杨涛涛 提到MySQL临时表,我们都很熟悉了,一般来说,分为两类: 1. MySQL 临时表引擎,名字叫做 Memory。比如 create table tmp1(id int, str1 varchar(100) ) engine = memory; 由参数max_heap_table_size 来控制,超过报错。 2. 非临时表的引擎,这里又分为两类: 用户自定义的临时表,比如: create temporary table (id int, str1 varchar(100) ); SQL执行过程中产生的内部临时表,比如:UNION , 聚合类ORDER BY,派生表,大对象字段的查询,子查询或者半连接的固化等等场景。 那么这两种临时表的计数器通常用 show global status like '%tmp_%tables%' 来查看。比如 mysql> show status like '%tmp_%tables%';` `+-------------------------+-------+` `| Variable_name | Value |` `+-------------------------+-------+` `| Created_tmp_disk_tables | 0 |

MySQL性能优化方案

对着背影说爱祢 提交于 2019-12-29 21:39:32
欢迎访问我的个人博客:www.ifueen.com MySql性能优化策略 文章目录 MySql性能优化策略 关系型数据库的优化方案 定位慢查询 找出执行效率慢的SQL(定位慢SQL) 开启慢查询记录日志 分析Sql语句 单机优化 通过表结构设计 数据库设计三范式 存储引擎 Innodb和MyISAM的区别 索引 索引分类 复合索引使用事项: 分表 垂直分表 水平分表 SQL语句优化 DDL优化 DML优化 DQL优化 关系型数据库的优化方案 关于MySQL的优化,大体方案可以分为以下步骤 找出执行效率低的Sql 分析慢的Sql 进行优化 定位慢查询 找出执行效率慢的SQL(定位慢SQL) 首先要明白原理,实际上我们在数据库上面所做的操作都会被日志记录下来,我们在定位慢查询就需要去通过日志记录来找到到底是哪条SQL效率慢 查询数据库状态的命令 运行了多久 show status like 'uptime' ; CRUD的执行次数 show status like '%Com_select%' show status like '%Com_insert%' show status like '%Com_update%' show status like '%Com_delete%' 查询所有的连接数 show status like 'connections' 查询慢查询次数 (

MySQL应用优化

落花浮王杯 提交于 2019-12-28 10:15:59
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 一、基本语句优化原则 (1).尽量避免在索引列上进行运算或函数操作,这样会导致索引失效 如: select * from t where Year(d)>=2016; 可以优化为: select * from t where d>='2016-01-01'; (2).使用join语句时,应用小结果集驱动大结果集。因为在join多表时,可能会导致更多的锁定和拥塞 (3).注意模糊查询时避免%%,%开头的查询条件会使索引失效 (4).仅列出需要查询的字段,这对效率没有影响,但会影响内存 如: select * from t; 可以优化为: select name from t; (5).使用批量交互插入语句以节省交互 如: insert into t(id,name) values(1,"a"); insert into t(id,name) values(2,"b"); 可以优化为: insert into t(id,name) values(1,"a"),(2,"b"); 这里也有博友质疑,贴结果: (6).limit的基数比较大时使用between 如: select * from article order by id limit 100000,10; 可以优化为: select * from

Query time result in MySQL w/ PHP

谁说我不能喝 提交于 2019-12-28 05:29:26
问题 Is there a way that I can get the time of a MySQL query (specifically with PHP)? The actual time it took to complete the query, that is. Something such as: Results 1 - 10 for brown. (0.11 seconds) I tried to look for an example, to no avail. Here is an example of my code: // prepare sql statement $stmt = $dbh->prepare("SELECT ijl, description, source, user_id, timestamp FROM Submissions WHERE MATCH (ijl, description) AGAINST (?)"); // bind parameters $stmt->bindParam(1, $search, PDO::PARAM

Should I always prefer MySQL InnoDB over MyISAM?

我的梦境 提交于 2019-12-28 05:10:21
问题 Someone just told me that InnoDB is much better than MyISAM. So when I create a table, should I always try to use InnoDB Engine instead of MyISAM? Or do both have it's big benefits? 回答1: MyISAM is transactionless and heap-organized. The records are identified by the row offset in the table and the indexes store this offset as a row pointer. InnoDB supports transactions and is index-organized. The records are identified by the value of the PRIMARY KEY (or a hidden internal column is there is