天堂

  :: :: 博问 :: 闪存 :: :: :: 订阅 订阅 :: 管理 ::

2013年3月11日

摘要: 原文链接:http://www.mysqlops.com/2011/12/20/understanding_index2.html如果要看“由浅入深理解索引的实现(1)”,请点这里。教科书上的B+Tree是一个简化了的,方便于研究和教学的B+Tree。然而在数据库实现时,为了 更好的性能或者降低实现的难度,都会在细节上进行一定的变化。下面以InnoDB为例,来说说 这些变化。04 - Sparse Index中的数据指针 在“由浅入深理解索引的实现(1)”中提到,Sparse Index中的每个键值都有一个指针指向 所在的数据页。这样每个B+Tree都有指针指向数据页。如图Fig.1所示:F. 阅读全文
posted @ 2013-03-11 16:03 zuoxingyu 阅读(235) 评论(0) 推荐(0) 编辑

摘要: 原文链接:http://www.mysqlops.com/2011/11/24/understanding_index.html00 – 背景知识- B-Tree & B+Tree http://en.wikipedia.org/wiki/B%2B_tree http://en.wikipedia.org/wiki/B-tree- 折半查找(Binary Search) http://en.wikipedia.org/wiki/Binary_search_algorithm- 数据库的性能问题 A. 磁盘IO性能非常低,严重的影响数据库系统的性能。 B. 磁盘顺序读写比随机读写的性能高 阅读全文
posted @ 2013-03-11 16:02 zuoxingyu 阅读(198) 评论(0) 推荐(0) 编辑

2013年3月7日

摘要: select*fromscwhere(selectcount(*)fromscsc2wheresc2.score>sc.scoreandsc2.class=sc.class)<=2orderbysc.class,sc.scoredesc;select*fromschaving(selectcount(*)fromsct1wheret1.class=sc.classandt1.score>=sc.score)<=3;select*fromscwhereexists(selectcount(*)fromscsc2wheresc2.score>sc.scoreandsc 阅读全文
posted @ 2013-03-07 16:39 zuoxingyu 阅读(207) 评论(0) 推荐(0) 编辑

2013年3月1日

摘要: 在这篇文章里,Peter讲述了一个例子,通过不同的办法做optimize,效率居然相差有20倍。在INNODB里,optimize table 操作会被重写为recreate + analyze,表被重建,这和做alter table的过程相似。下面测试下这个方法对于alter table 是不是同样有效,从理论上来说,plugin innodb 或5.6里增加的fast index creation特性,增加删除索引都不做load data操作,应该会快一些。<<<<<<<<<<<<<<<<< 阅读全文
posted @ 2013-03-01 16:21 zuoxingyu 阅读(379) 评论(1) 推荐(0) 编辑

2013年2月26日

摘要: 原文链接:http://www.mysqlperformanceblog.com/2010/12/09/thinking-about-running-optimize-on-your-innodb-table-stop/Innodb/XtraDB tables do benefit from being reorganized often. You can get data physically laid out in primary key order as well as get better feel for primary key and index pages and so usin 阅读全文
posted @ 2013-02-26 17:40 zuoxingyu 阅读(969) 评论(0) 推荐(0) 编辑

摘要: 原文链接:http://www.mysqlperformanceblog.com/2011/11/29/innodb-vs-mysql-index-counts/I had a customer recently who a few strange errors in their mysqld.err log:最近在一个客户的错误日志里面发现一些奇怪的错误[ERROR] Table database_name/table_name contains 8 indexes inside InnoDB, which is different from the number of indexes 7 阅读全文
posted @ 2013-02-26 15:04 zuoxingyu 阅读(630) 评论(0) 推荐(0) 编辑

2013年2月22日

摘要: 原文链接:http://blog.jobbole.com/24006/摘要本文以MySQL数据库为研究对象,讨论与数据库索引相关的一些话题。特别需要说明的是,MySQL支持诸多存储引擎,而各种存储引擎对索引的支持也各不相同,因此MySQL数据库支持多种索引类型,如BTree索引,哈希索引,全文索引等等。为了避免混乱,本文将只关注于BTree索引,因为这是平常使用MySQL时主要打交道的索引,至于哈希索引和全文索引本文暂不讨论。文章主要内容分为三个部分。第一部分主要从数据结构及算法理论层面讨论MySQL数据库索引的数理基础。第二部分结合MySQL数据库中MyISAM和InnoDB数据存储引擎中索 阅读全文
posted @ 2013-02-22 11:28 zuoxingyu 阅读(212) 评论(0) 推荐(0) 编辑

2013年2月20日

摘要: 原文链接:http://www.mysqlperformanceblog.com/2012/03/23/best-kept-mysqldump-secret/Many people use mysqldump –single-transaction to get consistent backup for their Innodb tables without making database read only. In most cases it works, but did you know there are some cases when you can get table entire 阅读全文
posted @ 2013-02-20 14:42 zuoxingyu 阅读(2154) 评论(0) 推荐(0) 编辑

摘要: 前面在一个朋友的项目里面分析慢查询日志的时,看到注释也记录在日志里面,而且注释内容比较巧妙,如/* module_name-function_name*/,在SQL里面嵌入了使用这个SQL的模块和函数名称,这在调查SQL出处的时候非常方便。用别的办法比如全代码搜索,然后一个个看也可以做到。当时对注释是如何记录到日志的没明白怎么做到的,今天看到这篇文章时,才注意到-c这个参数。文档里是这么说明的,默认是--skip-comments,不把注释发送到服务器 -c, --comments Preserve comments. Send comments to the server. Th... 阅读全文
posted @ 2013-02-20 10:51 zuoxingyu 阅读(459) 评论(0) 推荐(0) 编辑

2013年2月18日

摘要: DELIMITER // CREATE FUNCTION substr_count(in_haystack mediumtext, in_needle varchar(255), in_offset int unsigned, in_length int unsigned) RETURNS int unsigned LANGUAGE SQL DETERMINISTIC NO SQL SQL SECURITY INVOKER BEGIN DECLARE v_count, v_haystack_len, v_needle_len, v_offset, v_endpos int u... 阅读全文
posted @ 2013-02-18 14:16 zuoxingyu 阅读(227) 评论(0) 推荐(0) 编辑