`
stephen80
  • 浏览: 103991 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

shard tech decision

    博客分类:
  • j2ee
阅读更多
We recommend HiveDB plus Dual Master for most installations
Hibernate shard.

local cache with ehcache.
distributed cache with memcached.

  15、使用索引的缺点
  1)减慢增删改数据的速度;
  2)占用磁盘空间;
  3)增加查询优化器的负担;
  当查询优化器生成执行计划时,会考虑索引,太多的索引会给查询优化器增加工作量,导致无法选择最优的查询方案;
  
  16、分析索引效率
  方法:在一般的SQL语句前加上explain;
  分析结果的含义:
  1)table:表名;
  2)type:连接的类型,(ALL/Range/Ref)。其中ref是最理想的;
  3)possible_keys:查询可以利用的索引名;
  4)key:实际使用的索引;
  5)key_len:索引中被使用部分的长度(字节);
  6)ref:显示列名字或者"const"(不明白什么意思);
  7)rows:显示MySQL认为在找到正确结果之前必须扫描的行数;
  8)extra:MySQL的建议;
  
  17、使用较短的定长列
  1)尽可能使用较短的数据类型;
  2)尽可能使用定长数据类型;
  a)用char代替varchar,固定长度的数据处理比变长的快些;
  b)对于频繁修改的表,磁盘容易形成碎片,从而影响数据库的整体性能;
  c)万一出现数据表崩溃,使用固定长度数据行的表更容易重新构造。使用固定长度的数据行,每个记录的开始位置都是固定记录长度的倍数,可以很容易被检测到,但是使用可变长度的数据行就不一定了;
  d)对于MyISAM类型的数据表,虽然转换成固定长度的数据列可以提高性能,但是占据的空间也大;
  
  18、使用not null和enum
  尽量将列定义为not null,这样可使数据的出来更快,所需的空间更少,而且在查询时,MySQL不需要检查是否存在特例,即null值,从而优化查询;
  如果一列只含有有限数目的特定值,如性别,是否有效或者入学年份等,在这种情况下应该考虑将其转换为enum列的值,MySQL处理的更快,因为所有的en

um值在系统内都是以标识数值来表示的;



If you do store UUID values, you should remove the dashes or, even better, convert
the UUID values to 16-byte numbers with UNHEX( ) and store them in a
BINARY(16) column. You can retrieve the values in hexadecimal format with the
HEX( ) function.
Values generated by UUID( ) have different characteristics from those generated
by a cryptographic hash function such ash SHA1( ): the UUID values are unevenly
distributed and are somewhat sequential. They’re still not as good as a monotonically
increasing integer, though.

use Hash indexes when possible

Isolate the Column

If you’re using InnoDB and don’t need any particular clustering, it can be a good idea
to define a surrogate key, which is a primary key whose value is not derived from
your application’s data. The easiest way to do this is usually with an AUTO_INCREMENT
column. This will ensure that rows are inserted in sequential order and will offer better
performance for joins using primary keys.
It is best to avoid random (nonsequential) clustered keys. For example, using UUID
values is a poor choice from a performance standpoint: it makes clustered index
insertion random, which is a worst-case scenario, and does not give you any helpful
data clustering.
To demonstrate,

Where possible, try to extend existing indexes rather than adding new ones. It is usually
more efficient to maintain one multicolumn index than several single-column
indexes. If you don’t yet know your query distribution, strive to make your indexes as
selective as you can, because highly selective indexes are usually more beneficial

multicolumn index than several single-column
As a summary: Use multi column indexes is typically best idea if you use AND between such columns in where clause. Index merge does helps performance but it is far from performance of combined index in this case. In case you're using OR between columns - single column indexes are required for index merge to work and combined indexes can't be used for such queries

high performance

You may have noticed that we’re keeping the age column at the end of the index.

Avoiding Multiple Range Conditions

We can add special indexes for sorting these low-selectivity cases. For example, an
index on (sex,rating) can be used for the following query:
mysql> SELECT <cols> FROM profiles WHERE sex='M' ORDER BY rating LIMIT 10;

Clustering by primary key
All InnoDB tables are clustered by the primary key, which you can use to your
advantage in schema design.
All indexes contain the primary key columns
so if you don’t keep your primary
key short, the indexes will grow very large.

Slow data load
As of MySQL 5.0, InnoDB does not specially optimize data load operations. It
builds indexes a row at a time, instead of building them by sorting. This may
result in significantly slower data loads.

Foreign keys aren’t free.
Instead of using foreign keys as constraints, it’s often a good idea to constrain the
values in the application.
分享到:
评论

相关推荐

    Mongodb shard 简介

    "Mongodb shard 简介" MongoDB shard 是一种水平方向的多节点数据分散存储技术,它可以将大量数据分布到多个服务器上,以提高数据库的存储能力和查询效率。下面是 MongoDB shard 的一些特性和部署架构: Shard 的...

    Polygon_unity3d_多边形shard_

    在Unity3D游戏引擎中,"Polygon_unity3d_多边形shard_"这个主题主要涉及到了如何创建和操作多边形图形。多边形是3D图形的基础元素,通常用于构建复杂的3D模型。在Unity3D中,我们可以使用各种技术来生成和编辑多边形...

    android shard分享

    在Android开发中,"android shard分享"涉及到的是应用内实现社交分享功能的技术。"shard"在这里可能是"shared"的误拼,指的是共享或分享。ShareSDK是为Android开发者提供的一种便捷的社交分享解决方案,它整合了众多...

    shard-源码.rar

    《深入解析Shard源码》 在分布式数据库领域,Shard是一个重要的概念,它涉及到数据库的水平扩展,通过数据分片来解决单个数据库性能瓶颈的问题。本文将深入探讨Shard-源码,揭示其背后的设计思想和技术实现,帮助...

    mysql 分库分表查询工具-shard.zip

    MySQL 分库分表查询工具——Shard 在大型的互联网应用中,数据库的性能瓶颈往往成为系统扩展性的关键因素。为了应对高并发、大数据量的挑战,MySQL 数据库的分库分表策略被广泛采用。分库是将数据分散到多个独立的...

    shard:GUI文件加密工具

    碎片Shard 是一种加密工具,可让您将文件拆分为“分片”,因此只有将一定数量的分片重新组合在一起才能恢复原始文件。 警告: Shard 是实验性软件,其安全性尚未得到验证。 请不要依赖 Shard 来获取重要文件。截图...

    shard解包工具

    "shard解包工具"是一款专门针对iOS平台设计的解包和封包工具,它为开发者和逆向工程师提供了一种高效、便捷的方式来探索和理解应用程序的内部结构。这款工具的强大之处在于它能够帮助我们查看并分析二进制资源、处理...

    mongo-shard-docker-compose

    受启发Mongo组件Config Server(3个成员副本集): config01 , config02 , config03 3个碎片(每个2个成员副本集): shard01a , shard01b shard02a ,分片shard02b shard03a shard03b 1个路由器(mongos): ...

    Invalid Shard Key(解决方案).md

    Invalid Shard Key(解决方案).md

    Invalid Shard Configuration(解决方案).md

    Invalid Shard Configuration(解决方案).md

    springboot整合shard-jdbc,实现数据分库分表

    springboot系列教程(十八):springboot整合shard-jdbc,实现数据分库分表

    redis-shard:Redis分片客户端库

    用法首先,创建一个具有多个节点的RedisShardAPI实例,节点name必须是唯一的: from redis_shard.shard import RedisShardAPIservers = [ {'name': 'server1', 'host': '127.0.0.1', 'port': 10000, 'db': 0}, {'...

    shard-testtesttesttest

    在IT行业中,"shard"一词通常与数据库分片技术相关,这是一项用于扩展数据库性能和可伸缩性的策略。"test"标签可能表明这是一个测试环境或涉及测试过程的项目。"sendinfo-paas-shared"可能是项目中的一个模块或者...

    shard_handler:用于Rails应用程序的简单分片解决方案

    gem 'shard_handler' 然后执行: $ bundle 或将其自己安装为: $ gem install shard_handler 用法 首先,您必须创建一个将在分片连接之间切换的抽象模型: class Shard &lt; ShardHandler :: Model self . ...

    redis-sentinel-shard:用于哨兵的 redis clinet 分片

    redis-sentinel-shard 封装 ,实现客户端分片,使用 sentinel 的 master 名称作为哈希输入。演示 cd examples/redis_conf/# 1 master 2 slaves named m6381redis-server --port 6381redis-server ./6381_slave1.conf...

    Shard:用于Spring Engine的可重编程AI框架

    Shard是一款与引擎无关的RTS AI游戏框架。 当前正在实现Spring RTS Engine。 它提供了带有包装器的C ++ API,用于在lua环境中编写AI代码。 最好的文档位于尽管下面有一些最突出的信息 建造弹簧引擎 对于* nix操作...

    Mongodb增加、移除Shard Server实例

    使用 `runCommand` 方法在配置服务器上添加新的 Shard,指定 Shard 的名称、包含的节点列表以及可选的最大数据大小(例如 20GB)。 4. **验证操作:** 分片操作完成后,可以通过 `printShardingStatus()` 命令...

    MongoDB资料shard,oplog等

    ### MongoDB核心知识点解析 #### MongoDB概述 MongoDB是一款高性能、开源、无模式的文档型数据库。作为一款介于关系数据库和非关系数据库之间的解决方案,MongoDB在很多应用场景中可以替代传统的关系型数据库或是...

    elasticsearch-shard-suggester

    弹性搜索碎片建议elasticsearch-shard-suggester是一个脚本,该脚本根据当前索引的搜索性能来建议第二天索引中的最佳主碎片数。版本0.02怎么跑 1.虚拟环境设置$ git clone git@github....

Global site tag (gtag.js) - Google Analytics