




已阅读5页,还剩158页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
阿里巴巴分布式数据库,原理、实现和应用,2012.11,集团共享技术平台 分布式数据库 邱硕,2012华东架构师大会,分布式数据库中间件,App,App,App,App,Cobar,Oracle,MySQL,MySQL,MySQL,Erosa Oracle,Erosa MySQL,Erosa MySQL,Erosa MySQL,Eromanga,Otter,Oracle,MySQL,MySQL,Otter,Erosa Oracle,Erosa MySQL,Erosa MySQL,Eromanga,性能 容量 高可用 数据消费时效性 跨机房数据同步,ASC,DW,.,分布式数据库中间件,App,App,App,App,Cobar,Oracle,MySQL,MySQL,MySQL,Erosa Oracle,Erosa MySQL,Erosa MySQL,Erosa MySQL,Eromanga,Oracle,MySQL,MySQL,Otter,性能 容量 高可用 数据消费时效性 跨机房数据同步,Erosa Oracle,Erosa MySQL,Erosa MySQL,Eromanga,Otter,ASC,DW,.,分布式数据库中间件,App,App,App,App,Cobar,Oracle,MySQL,MySQL,MySQL,Oracle,MySQL,MySQL,Otter,Erosa Oracle,Erosa MySQL,Erosa MySQL,Eromanga,性能 容量 高可用 数据消费时效性 跨机房数据同步,Erosa Oracle,Erosa MySQL,Erosa MySQL,Erosa MySQL,Eromanga,Otter,ASC,DW,.,分布式数据库中间件,App,App,App,App,Cobar,Oracle,MySQL,MySQL,MySQL,Erosa Oracle,Erosa MySQL,Erosa MySQL,Erosa MySQL,Eromanga,Oracle,MySQL,MySQL,Erosa Oracle,Erosa MySQL,Erosa MySQL,Eromanga,性能 容量 高可用 数据消费时效性 跨机房数据同步,Otter,ASC,DW,.,Otter,分布式数据库中间件,App,App,App,App,Cobar,Oracle,MySQL,MySQL,MySQL,Erosa Oracle,Erosa MySQL,Erosa MySQL,Erosa MySQL,Eromanga,Oracle,MySQL,MySQL,Otter,性能 容量 高可用 数据消费时效性 跨机房数据同步,Erosa Oracle,Erosa MySQL,Erosa MySQL,Eromanga,Otter,ASC,DW,.,大纲,中间件引入 Cobar策略 系统实现 实施应用,Cobar之前,Oracle单点数据库 性能问题 中文站offer总数:2008年1亿 - 2011年3亿 高峰时:load 30、cpu使用率90% 数据库连接过多 可用性问题 Standby切换故障 成本和伸缩性问题 依赖高成本的硬件设备,Oracle,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,单点:MySQL集群替换Oracle,MySQL,MySQL,MySQL,Oracle单点数据库 性能问题 中文站offer总数:08年1亿 - 今天3亿 高峰时:load 30、cpu使用率90% 数据库连接过多 可用性问题 Standby切换故障 成本和伸缩性问题 依赖高成本的硬件设备,Cobar引入 水平拆分,MySQL,MySQL,MySQL,Cobar,App,Oracle单点数据库 性能问题 中文站offer总数:08年1亿 - 今天3亿 高峰时:load 30、cpu使用率90% 数据库连接过多 可用性问题 Standby切换故障 成本和伸缩性问题 依赖高成本的硬件设备,App,MySQL,MySQL,MySQL,App,App,App,App,App,App,App,Cobar引入 连接复用,App,MySQL,MySQL,MySQL,Cobar Proxy,App,App,App,App,App,App,App,Oracle单点数据库 性能问题 中文站offer总数:08年1亿 - 今天3亿 高峰时:load 30、cpu使用率90% 数据库连接过多 可用性问题 Standby切换故障 成本和伸缩性问题 依赖高成本的硬件设备,Cobar引入,MySQL,Cobar,App,X,Cobar引入 failover,MySQL Master1,Cobar,App,MySQL Master2,X,MySQL Replication,Cobar引入 failover,Cobar,App,MySQL Replication,MySQL Master1,MySQL Master2,大纲,中间件引入 Cobar策略 系统实现 实施应用,Oracle,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,MySQL,拆分数据表,水平拆分,水平拆分,拆分字段,水平拆分,f(pavarotti17)=库1,f(test1234)=库1,f(test1234)=库1,f(pavarotti17)=库1,f(abcd)=库2,f(abcd)=库2,f(abcd)=库2,库1,库2,拆分字段,水平拆分,f(abcd)=库2,库1,库2,拆分字段,f(pavarotti17)=库1,f(test1234)=库1,f(test1234)=库1,f(pavarotti17)=库1,f(abcd)=库2,f(abcd)=库2,路由算法,路由算法,pavarotti17,f(pavarotti17)=库1,路由算法,pavarotti17,部分截取,hash( ) = 3170972965401,路由算法,hash(pavarott) = 3170972965401 % 1024 = 537,0 1023,路由算法,hash(pavarott) = 3170972965401 % 1024 = 537,0 255,256 511,512 767,768 1023,256,256,256,256,分库1,分库2,分库3,分库4,路由算法,hash(pavarott) = 3170972965401 % 1024 = 537,0 255,256 511,512 767,768 1023,256,256,256,256,分库1,分库2,分库3,分库4,路由算法扩容,hash(pavarott) = 3170972965401 % 1024 = 537,0 127 128 255,256 383 384 511,512 639 640 767,768 895 896 1023,128,128,128,128,128,128,128,128,分库1,分库2,分库3,分库4,路由算法扩容,hash(pavarott) = 3170972965401 % 1024 = 537,0 127 128 255,256 383 384 511,512 639 640 767,768 895 896 1023,128,128,128,128,128,128,128,128,分库1,分库2,分库3,分库4,分库5,分库6,分库7,分库8,原,分库1,分库2,分库3,分库4,原,原,原,路由算法非均匀分布,hash(pavarott) = 3170972965401 % 1024 = 537,0 511,512 767,768 895 896 1023,512,256,128,128,分库1,分库2,分库3,分库4,拆分表的数据访问SQL转发,Cobar,App,select * from tb1 where member_id=test1234,拆分表的数据访问SQL转发,Cobar,App,select * from tb1 where member_id=test1234,Cobar,App,SELECT * FROM tb1 WHERE member_id IN (test1234,pavarotti17,abcd),拆分表的数据访问SQL转发,Cobar,App,select * from tb1 where member_id in (test1234,pavarotti17),select * from tb1 where member_id in (abcd),拆分表的数据访问SQL转发,Result Merger,前台 通信,ResultSet:row1 row2,ResultSet:row3 row4 row5,ResultSet:row3 row1 row4 row5 row2,拆分表的数据访问结果返回,多维水平拆分,visit表,SELECT * FROM visit WHERE user=A,多维水平拆分,visit表,SELECT * FROM visit WHERE product = Coca-Cola,分库1,分库2,分库3,分库4,分库5,分库6,分库7,分库8,分库9,分库10,分库11,分库12,分库13,分库14,分库15,分库16,product值 Hash取模,user值 Hash取模,0,1,2,3,0,1,2,3,visit表,一张表的多个字段同时作为拆分字段,Hash(“A”)%4 =,分库1,分库2,分库3,分库4,分库5,分库6,分库7,分库8,分库9,分库10,分库11,分库12,分库13,分库14,分库15,分库16,product值 Hash取模,user值 Hash取模,0,1,2,3,0,1,2,3,CocaCola A,Hash(“CocaCola”)%4 =,SELECT * FROM visit WHERE product=ColaCola AND user=A,分库1,分库2,分库3,分库4,分库5,分库6,分库7,分库8,分库9,分库10,分库11,分库12,分库13,分库14,分库15,分库16,product值 Hash取模,user值 Hash取模,0,1,2,3,0,1,2,3,CocaCola,Hash(“CocaCola”)%4 =,SELECT * FROM visit WHERE product=ColaCola,Hash(“A”)%4 =,A,分库1,分库2,分库3,分库4,分库5,分库6,分库7,分库8,分库9,分库10,分库11,分库12,分库13,分库14,分库15,分库16,product值 Hash取模,user值 Hash取模,0,1,2,3,0,1,2,3,SELECT * FROM visit WHERE product=ColaCola AND user=A,Cobar的策略,MySQL集群替代Oracle单点 基于表的水平拆分和分布 根据字段值的一致性Hash分布 多维拆分 数据查询方式 根据where中的拆分字段分发 SQL语句其他元素的处理 将Cobar收到的SQL语句做变换 分发到各个分库执行 对执行结果合并、处理 保证返回前端的内容满足语义,JOIN有限的处理,跨库JOIN问题,SELECT * FROM tb1 INNER JOIN tb2 ON t1.MEMBER_ID=t2.NAME,tb1,tb1,tb2,tb2,迭代查询,SELECT * FROM tb1 INNER JOIN tb2 ON t1.MEMBER_ID=t2.NAME,tb1,tb1,tb2,tb2,FOR row1 IN select * FROM tb1 ADD( SELECT * FROM tb2 WHERE = row1.member_id )TO RESULT ,跨库索引,tb1,tb1,tb2,tb2,idx,idx,扫描idx,再根据每一行的id1,id2查到最终结果,跨库索引,tb1,tb1,tb2,tb2,SELECT * FROM tb1 INNER JOIN tb2 ON t1.MEMBER_ID=t2.NAME WHERE t1.id = 5,SELECT * FROM idx WHERE id1 = 5,再根据id1,id2查到最终结果,跨库索引,tb1,tb1,tb2,tb2,idx,idx,一定以 JOIN_COL 为索引的拆分字段吗?,跨库索引,SELECT * FROM tb1 INNER JOIN tb2 ON t1.MEMBER_ID=t2.NAME WHERE t1.gmt600,tb1,tb1,tb2,tb2,跨库索引,tb1,tb1,tb2,tb2,idx,idx,tb1,tb1,tb2,tb2,idx,idx,SELECT idx.id2, tb1.* FROM idx INNER JOIN tb1 ON idx.id1=tb1.id WHERE t1.gmt600,SELECT idx.id2, tb1.* FROM idx INNER JOIN tb1 ON idx.id1=tb1.id WHERE t1.gmt600,SELECT * FROM tb1 INNER JOIN tb2 ON t1.MEMBER_ID=t2.NAME WHERE t1.gmt600,跨库索引,跨库索引,tb1,tb1,tb2,tb2,SELECT * FROM tb1 INNER JOIN tb2 ON t1.MEMBER_ID=t2.NAME WHERE t1.gmt600 AND t2.time600,idx,跨库索引,idx,idx,索引表的拆分 WHERE条件中的字段所在表的拆分字段,作为索引拆分字段 索引包含 两张表的主键 JOIN字段 WHERE中的其他字段 索引的更新 分布式事务的支持,SELECT c1 FROM tb1 ORDER BY c1 LIMIT 4, 2,select . order by c1 limit 0, 6,select . order by c1 limit 0, 6,select . order by c1 limit 0, 6,分库1,分库2,分库3,cobar,Order By/Limit,分库1,分库2,分库3,Order By/Limit,4,5,6,3,2,7,8,10,6,5,1,11,13,14,9,7,3,返回结果,返回结果,返回结果,8,SELECT c1 FROM tb1 ORDER BY c1 LIMIT 4, 2,分库1,分库2,分库3,Order By/Limit,4,5,6,3,2,7,8,10,6,5,1,11,13,14,9,7,3,返回结果,返回结果,返回结果,8,0,最终结果集,SELECT c1 FROM tb1 ORDER BY c1 LIMIT 4, 2,分库1,分库2,分库3,Order By/Limit,4,5,6,3,2,7,8,10,6,5,11,13,14,9,7,3,返回结果,返回结果,返回结果,8,1,最终结果集,SELECT c1 FROM tb1 ORDER BY c1 LIMIT 4, 2,分库1,分库2,分库3,Order By/Limit,4,5,6,3,7,8,10,6,5,11,13,14,9,7,3,返回结果,返回结果,返回结果,8,2,最终结果集,SELECT c1 FROM tb1 ORDER BY c1 LIMIT 4, 2,分库1,分库2,分库3,Order By/Limit,4,5,6,7,8,10,6,5,11,13,14,9,7,3,返回结果,返回结果,返回结果,8,3,最终结果集,SELECT c1 FROM tb1 ORDER BY c1 LIMIT 4, 2,分库1,分库2,分库3,Order By/Limit,4,5,6,7,8,10,6,5,11,13,14,9,7,返回结果,返回结果,返回结果,8,4,最终结果集,SELECT c1 FROM tb1 ORDER BY c1 LIMIT 4, 2,最终结果集,分库1,分库2,分库3,Order By/Limit,5,6,7,8,10,6,5,11,13,14,9,7,返回结果,返回结果,返回结果,8,4,4,SELECT c1 FROM tb1 ORDER BY c1 LIMIT 4, 2,最终结果集,分库1,分库2,分库3,Order By/Limit,4,6,7,8,10,6,5,11,13,14,9,7,返回结果,返回结果,返回结果,8,4,5,SELECT c1 FROM tb1 ORDER BY c1 LIMIT 4, 2,Order By/Limit 方案总结,select c1 from tb1 order by c1 limit 100000000, 2,所有分库都要查询100000002条数据 Cobar需要遍历100000002条数据,对如下SQL,一次交互得到结果 Offset大小有限制,Order By / Limit 优化,目标:解决 查询量大问题 遍历量大问题 前提 各个分库数据分布大致一样,select c1 from tb1 order by c1 limit 9999999, 4,select . order by c1 limit 33333333, 4,select . order by c1 limit 33333333, 4,select . order by c1 limit 33333333, 4,分库1,分库2,分库3,step1:分成3条语句发给分库,分库1,分库2,分库3,7,4,5,3,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,select c1 from tb1 order by c1 limit 9999999, 4,找出查询结果中最小和最大值,分库1,分库2,分库3,7,4,5,3,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,step2:以最小值和最大值为界再查询,select c1 from tb1 order by c1 limit 9999999, 4,3,11,5,3,11,分库1,分库2,分库3,7,4,5,3,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,step3:反查出每一个返回结果的offset,select c1 from tb1 order by c1 limit 9999999, 4,3,11,5,3,11,33333331条,33333333条,33333332条,分库1,分库2,分库3,7,4,5,3,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,类似于原始方案,select c1 from tb1 order by c1 limit 9999999, 4,3,11,5,3,11,9999996,分库1,分库2,分库3,7,4,5,3,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,类似于原始方案,select c1 from tb1 order by c1 limit 9999999, 4,11,5,3,11,9999997,分库1,分库2,分库3,7,4,5,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,类似于原始方案,select c1 from tb1 order by c1 limit 9999999, 4,11,5,3,11,9999998,分库1,分库2,分库3,7,4,5,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,类似于原始方案,select c1 from tb1 order by c1 limit 9999999, 4,11,5,11,9999999,最终结果集,最终结果集,分库1,分库2,分库3,7,4,5,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,类似于原始方案,select c1 from tb1 order by c1 limit 9999999, 4,11,5,11,9999999,最终结果集,分库1,分库2,分库3,7,4,5,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,类似于原始方案,select c1 from tb1 order by c1 limit 9999999, 4,11,5,11,9999999,最终结果集,分库1,分库2,分库3,7,4,5,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,类似于原始方案,select c1 from tb1 order by c1 limit 9999999, 4,11,5,11,9999999,最终结果集,分库1,分库2,分库3,7,4,5,8,6,9,10,7,6,11,9,返回结果,返回结果,返回结果,类似于原始方案,select c1 from tb1 order by c1 limit 9999999, 4,11,5,11,9999999,Order By / Limit 再优化,Step1不必得到全部结果 select min(c1) mi, max(c1) ma from (select c1 from tb1 order by c1 limit 3333333,4) t Step2和Step3合并 select * from (select * from tb1 where c1 between mi and ma) t1, (select count(*) from tb1 where c1 mi) t2,Group By,SELECT sum(price) FROM tb1 GROUP BY c1,Group By,SELECT sum(price) FROM tb1 GROUP BY c1,SELECT sum(price), c1 FROM tb1 GROUP BY c1 ORDER BY c1,12.3 2222,7.9 131,8.8 604,99.9 56,7.6 131,4.4 604,Group By,SELECT sum(price) FROM tb1 GROUP BY c1,SELECT sum(price), c1 FROM tb1 GROUP BY c1 ORDER BY c1,12.3 2222,7.9 131,8.8 604,7.6 131,4.4 604,最终结果集,99.9 56,Group By,SELECT sum(price) FROM tb1 GROUP BY c1,SELECT sum(price), c1 FROM tb1 GROUP BY c1 ORDER BY c1,12.3 2222,7.9 131,8.8 604,7.6 131,4.4 604,最终结果集,99.9 56,最终结果集,Group By,SELECT sum(price) FROM tb1 GROUP BY c1,SELECT sum(price), c1 FROM tb1 GROUP BY c1 ORDER BY c1,12.3 2222,15.5 131,8.8 604,4.4 604,99.9 56,最终结果集,Group By,SELECT sum(price) FROM tb1 GROUP BY c1,SELECT sum(price), c1 FROM tb1 GROUP BY c1 ORDER BY c1,12.3 2222,15.5 131,13.2 604,99.9 56,最终结果集,Group By,SELECT sum(price) FROM tb1 GROUP BY c1,SELECT sum(price), c1 FROM tb1 GROUP BY c1 ORDER BY c1,12.3 2222,15.5 131,13.2 604,99.9 56,SQL执行策略总结,WHERE - 基于SQL转发 JOIN - 迭代 分布式索引 ORDER BY/LIMIT - 多次查询减小数据量 GROUP BY - 增加ORDER BY,Cobar 事务支持,前端连接,sql1,sql2,commit,Cobar 1.2 事务支持,前端连接,分库1连接,sql1,sql2,commit,Cobar 1.2 事务支持,前端连接,分库1连接,sql1,commit,分库2连接,sql2,分库3连接,sql2,Cobar 事务支持,前端连接,分库1连接,sql1,commit,分库2连接,sql2,分库3连接,sql2,Commit有先后:隔离性问题 Commit有失败:一致性问题,大纲,中间件引入 Cobar策略 水平拆分的数据分布 几种SQL元素的执行策略 事务策略 系统实现 实施应用,schema,tableSpace,dataNode,data source,cndb,pc2,主,备,主,备,default,offer0,主,备,offer1,主,备,detail0,主,备,default,default,offer,detail,detail,逻辑层次 接口同MySQL,jdbc:mysql:/cobarIp:8066/cndb?user=foo&password=bar,MySQL,MySQL,MySQL,Cobar结构,Front-end Communication,MySQL Protcol Adaptor (BIO),Application1,MySQL,MySQL,MySQL,Data Nodes,Monitor Configure,HA Pool,MySQL,MySQL,Processor(1),Processor(n),SQL Executor,SQL Router,SQL Parser,Result Merger,SQL Executor,SQL Router,SQL Parser,Result Merger,.,Manager,MySQL Protocol,MySQL Protocol,MySQL Protocol,MySQL Protocol,Management Protocol,MySQL,MySQL,MySQL,Cobar结构,Front-end Communication,MySQL Protcol Adaptor (BIO),Application1,MySQL,MySQL,MySQL,Data Nodes,Monitor Configure,HA Pool,MySQL,MySQL,Processor(1),Processor(n),SQL Executor,SQL Router,SQL Parser,Result Merger,SQL Executor,SQL Router,SQL Parser,Result Merger,.,Manager,MySQL Protocol,MySQL Protocol,MySQL Protocol,MySQL Protocol,Management Protocol,Application1,JDBC和Server的通信协议,MySQL JDBC Driver,MySQL Server,MySQL Protocol,JDBC和Server的通信协议,PreparedStatement ps = conn.prepareStatement( “select * from tb1 where id=?“); ps.setLong(1, 12345); ResultSet rs = ps.executeQuery();,MySQL Server,Application1,MySQL JDBC Driver,JDBC和Server的通信协议,MySQL Server,Application1,MySQL JDBC Driver,PreparedStatement ps = conn.prepareStatement( “select * from tb1 where id=?“); ps.setLong(1, 12345); ResultSet rs = ps.executeQuery();, select * from tb1 where id=?, stmt_id/param_num/columm_num, parameter_type, column_type,JDBC和Server的通信协议,PreparedStatement ps = conn.prepareStatement( “select * from tb1 where id=?“); ps.setLong(1, 12345); ResultSet rs = ps.executeQuery();,MySQL Server,Application1,MySQL JDBC Driver,JDBC和Server的通信协议,PreparedStatement ps = conn.prepareStatement( “select * from tb1 where id=?“); ps.setLong(1, 12345); ResultSet rs = ps.executeQuery();,MySQL Server,Application1,MySQL JDBC Driver, stmt_id param+, field_count, column_type, column_val+, column_val+,JDBC和Server的通信协议,Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery( “select * from tb1 where id=12345”);,Application1,MySQL JDBC Driver, sql, field_count, column_type, column_val+, column_val+,MySQL Server,JDBC和Server的通信协议,Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery( “select * from tb1 where id=12345”);,Application1,MySQL JDBC Driver, sql, field_count, column_type, column_val+, column_val+,MySQL Server,Cobar Server,Processor(1),Processor(n),MySQL,MySQL,MySQL,Cobar结构,Front-end Communication,MySQL Protcol Adaptor (BIO),Application1,MySQL,MySQL,MySQL,Data Nodes,Monitor Configure,HA Pool,MySQL,MySQL,SQL Executor,SQL Router,SQL Parser,Result Merger,SQL Executor,SQL Router,SQL Parser,Result Merger,.,Manager,MySQL Protocol,MySQL Protocol,MySQL Protocol,MySQL Protocol,Management Protocol,SQL +Parameters,ResultSetMetaData ResultSet(Rows),Cobar 通信层,统一管理NIO的Buffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,共16MB,Buffer Pool,Cobar 通信层,统一管理NIO的Buffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,共16MB,Buffer Pool, select * from tb1 where id=?,Cobar 通信层,统一管理NIO的Buffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,共16MB,Buffer Pool, select * from tb1 where id=?,Cobar 通信层,统一管理NIO的Buffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,4KB ByteBuffer,共16MB,Buffer Pool,15万,TPS,.,MySQL,MySQL,MySQL,Cobar结构,Front-end Communication,MySQL Protcol Adaptor (BIO),Application1,MySQL,MySQL Protocol,MySQL,MySQL,Data Nodes,Monitor Configure,HA Pool,MySQL,MySQL,Processor(1),Processor(n),SQL Executor,SQL Router,Result Merger,SQL Executor,SQL Router,Result Merger,Manager,MySQL Protocol,MySQL Protocol,MySQL Protocol,MySQL Protocol,Management Protocol,SQL Parser,SQL Parser,SELECT id, member_id FROM wp_image WHERE member_id = 123,SQL Parser,select,id,member_id,wp_image,=,member_id,123,exprList,from,架构演变,基于JavaCC生成SQL Parser 性能较差,优化不方便 仿照ANTLR生成的Parser结构手写 基于LL(*)的识别器,中间对象过多 基于LL(2)识别器的手写,第一版,第二版,第三版,架构调整,Lexer,token,token,token,token,Char Reader,Expression Parser,DML Parser,SQL String,Lexer,token,Expression Parser,DML Parser,SQL char,第三版LL(2),第二版LL(*),cache,功能对比,基本元素,语法元素,MySQL 5.5 语法结构,Identifier,Keyword,Literal,Punctuation,表达式,Table References,Limit,OrderBy,.,Delete,Update,Insert,Replace,Select,Call,Set/Show,SQL语句,Variable,基本元素,Keyword 227个关键字,不区分大小写 Identifier schema、table、column、index、alias 、keyword SELECT aNy FROM t1 WHERE id IN AnY (SELECT id FROM t2) select、table1 ./*spam*/id、7Up Punctuation ,、:=、!、 Variable User-Def SystemVariable:version,基本元素 - Literal,String Literal Nabc、_latin1abc、abc def ”abc”d”、abcd Number Literal 123、.123、123.、123.e4、.123E-4 123e4 vs 123e4f Hex/Bit Literal 0x89af、x89af、0b101011、b101011 _latin1 0x89af,基本元素,语法元素,MySQL 5.5 语法结构,Identifier,Keyword,Literal,Punctuation,表达式,Table References,Limit,OrderBy,.,Delete,Update,Insert,Replace,Select,Call,Set/Show,SQL语句,Variable,语法元素 Table References,table_references: table_reference , table_reference table_reference: table_factor INNER|CROSS JOIN table_factor join_condition | STRAIGHT_JOIN table_factor ON conditional_expr | (LEFT|RIGHT) OUTER JOIN table_reference join_condition | NATURAL (LEFT|RIGHT) OUTER JOIN table_factor table_factor: tbl_name AS alias index_hint_list | table_subquery AS alias | ( table_references ) join_condition: ON conditional_expr | USING (column_list) index_hint_list: index
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 农发行安康市白河县2025秋招数据分析师笔试题及答案
- 国家能源湖州市德清县2025秋招笔试言语理解与表达题专练及答案
- 军训个人小结(15篇)
- 午夜情感电台广播稿
- 卖房公证委托书(12篇)
- 双方合作协议书 (15篇)
- 6.19 七七事变与全民族抗战 说课稿 2025-2026学年部编版八年级历史上册
- 2024-2025学年九年级物理上册 第十五章 电能与电功率 15.2 认识电功率说课稿 (新版)粤教沪版
- 实训个人小结(15篇)
- 房地产公司年度工作总结15篇
- 监控验收单完整版本
- DL-T-5743-2016水电水利工程土木合成材料施工规范
- (正式版)YST 1682-2024 镁冶炼行业绿色工厂评价要求
- 体育健康知识教案课件
- 卡西欧dh800电吹管说明书
- 体育课免修申请书体育课免修申请书八篇
- 【超星尔雅学习通】商法的思维网课章节答案
- 509册泵类书籍大全-截止到20150531
- GB/T 5796.3-2022梯形螺纹第3部分:基本尺寸
- GA 576-2018防尾随联动互锁安全门通用技术条件
- 工厂化育苗基质与营养
评论
0/150
提交评论