搜索​​​​

清除过滤器
文章
Claire Zheng · 十一月 8, 2021

2021全球线上峰会划重点:计算的目的是洞察力,而不是数字

InterSystems 2021全球线上峰会精彩内容梳理:两个重磅论坛集中探讨Analytics(分析)的奥义,InterSystems数据平台与医疗行业的愿景分享!
文章
Claire Zheng · 九月 13, 2021

“InterSystems IRIS医疗版互联互通套件”线上发布会(9月17日)邀请报名启动

针对新近面向中国推出的InterSystems IRIS医疗版互联互通套件,InterSystems将在9月17日(本周五)举办“InterSystems IRIS医疗版互联互通套件”线上发布会,会议详情如下,欢迎点击“此处”或扫描下方二维码报名。此次会议为邀请参会制,收到您的报名信息后,我们会及时与您确认参会资格并发送会议链接。
问题
秀政 王 · 七月 2, 2021

ensemble引入Java jar包报错

错误详情 ERROR #5023: Remote Gateway Error: java.lang.NoClassDefFoundError: net/sf/cglib/proxy/MethodInterceptor at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source) at com.intersys.gateway.JavaGateway.loadClass(JavaGateway.java:1375) at com.intersys.gateway.Generator.generate(Generator.java:168) at com.intersys.gateway.JavaGateway.generateClasses(JavaGateway.java:794) at com.intersys.gateway.JavaGateway.processMessage(JavaGateway.java:565) at com.intersys.gateway.JavaGateway.run(JavaGateway.java:548) at com.intersys.gateway.JavaGateway.run(JavaGateway.java:519) Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.MethodInterceptor at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 20 more 1 您好!该问题请提交WRC服务. 您可以登录网址:https://wrc.intersystems.com提交 是不是缺了一个类:You're missing a JAR with net.sf.cglib.proxy.MethodInterceptor class. 是否未导入引用的jar包导致无法成功引用,可以在java网关向导中导入jar时,同时将依赖的jar进行导入
公告
Jeff Liu · 五月 21, 2021

Java业务主机现在已经不再使用

随着InterSystems IRIS 2020.1和InterSystems IRIS for Health 2020.1中PEX的发布,客户有了比Java Business Host更好的方式来构建Java的产品。PEX为构建互操作性组件提供了一套完整的API,并有Java和.NET两种版本。 从InterSystems IRIS和InterSystems IRIS for Health的2020.4版本开始,Java Business Host已经被删除。 我们鼓励使用Java商业主机的客户迁移到PEX。 PEX的优势 * 允许开发人员在Java或.NET中创建任何生产组件 * 组件之间可以传递更复杂的消息结构 * 简化设置 * S简化了开发工作流程,无需使用ObjectScript。 关于迁移到PEX的更多信息,请参见从Java Business Host迁移到PEX。
公告
Claire Zheng · 十一月 30, 2022

荣誉!InterSystems被独立研究机构Forrester评为“事务分析型数据平台领导者”

2022 年 12 月 1 日,中国,北京——致力于帮助客户解决最关键的可扩展性、互操作性和速度问题的创新数据技术提供商 InterSystems 今天宣布,在Forrester日前公布的《The Forrester Wave™:事务分析型数据平台(2022年第4季度)》报告中,InterSystems IRIS® 数据平台被评为领导者。 Forrester 将事务分析型数据平台(Translytical data platform)定义为“构建在单一数据库引擎上来支持多种数据类型和数据模型的下一代数据平台,旨在支持事务、操作和分析工作负载,而不牺牲数据完整性、性能和分析规模”。 InterSystems 认为实时(real-time)功能对事务分析型平台至关重要,是智能数据编织(smart data farics)的一个关键组成部分。这种方法基于数据和实时分析,为业务线用户提供洞察,使组织能够更快地管理中断(manage disruption),并在充满不确定和竞争日益激烈的环境中发现新的机会。 在评估过程中,Forrester 根据三个类别的标准对供应商进行了评分:当前产品、战略和市场占有率。InterSystems 在以下这些标准中均获得了最高分:建模/工具;可延展性(扩展平台的功能);可扩展性;产品愿景(与客户当前和未来需求一致);执行路线图;公司业绩以及工程师数量。 InterSystems IRIS® 数据平台 使企业能够快速开发、部署和执行数据密集型分析应用程序。通过让构建高性能、支持机器学习的应用程序变得更容易(这些应用程序可以连接数据和应用孤岛),InterSystems IRIS 简化了架构,赋能关键任务应用程序——当今企业需要这些应用程序快速解决棘手的业务难题。 InterSystems 数据平台副总裁 Scott Gnau 表示:“我们知道,在一个竞争更激烈、更动荡的世界中,企业需要更快地获得洞察以改进决策。InterSystems为客户提供了一些全新视角,这些视角只能来自于对所有相关数据的深入分析。” 通过创建智能数据编织(smart data fabric)架构,InterSystems IRIS 使企业能够做出更智能的决策,实现更好的结果。目前,一家管理着超过1万亿美元资产的全球投资银行正在使用 InterSystems IRIS 为其实时多资产交易平台提供动力,与之前的实施相比,InterSystems IRIS 令平台的可靠性、可扩展性和成本效益都得到了提升。得益于 InterSystems IRIS,银行表现提高了 10 倍,运营成本降低了 75%,吞吐量增加了 5 倍。 InterSystems IRIS 拥有如 InterSystems IRIS 自适应分析(可实现业务用户的自助服务)、IntegratedML(可用于公众数据科学),以及在编程工作流中执行实时分析的极端性能等优秀功能。InterSystems IRIS 部署在全球各地,可在多个公共云市场上使用,包括 Amazon Web Services、Microsoft Azure 和谷歌云平台。 点击“这里”,下载《The Forrester Wave™:事务分析型数据平台(2022年第4季度)》。
文章
Claire Zheng · 一月 4, 2023

【GS22 视频】智能数据编织:重塑数据利用方式,激活创新!

在InterSystems 2022年全球峰会上,InterSystems 数据平台负责人 Scott Gnau解读了智能数据编织(smart data fabric)及其实现方式。Scott 同时也是一位钢笔收藏家,他分享了自己学习收藏的过程,认为这种过程与智能数据编织有着异曲同工之妙。InterSystems IRIS数据平台的诸多优秀能力可以帮助用户实现智能数据编织,重塑数据利用方式!
公告
Jeff Liu · 七月 5, 2023

[视频] 为什么横向扩展就像团队合作

嗨,开发者, 欣赏InterSystems Bilibili上的新视频: ⏯为什么水平可扩展性就像团队合作 @ 2022 年全球峰会 借助 InterSystems IRIS,您可以跨节点集群分配数据和工作负载、扩展和扩展以及根据需要动态重新平衡。在本次会议中,您将了解有关该技术和我们的一些部署的更多信息。 🗣演讲者:@Benjamin.DeBoe,InterSystems 产品经理 享受它并保持关注! 👍
文章
TZ Zhuang · 八月 6, 2021

FAQ 常见问题系列--系统管理篇 如何使用命令在Journal日志文件中搜索指定的Global

可以使用%SYS.Journal.File类中的ByTimeReverseOrder查询,以及%SYS.Journal.Record类中的List查询来实现。 下面是这两个查询的具体作用: A) %SYS.Journal.File类中的ByTimeReverseOrder查询这个查询会获取journal日志文件名并按降序排列 USER>set rs=##class(%ResultSet).%New("%SYS.Journal.File:ByTimeReverseOrder") USER>do rs.Execute() USER>while rs.Next() { write rs.Name,! } c:\intersystems\cache\mgr\journal\20190620.003 c:\intersystems\cache\mgr\journal\20190620.002 c:\intersystems\cache\mgr\journal\20190620.001 c:\intersystems\cache\mgr\journal\20190610.001 B) %SYS.Journal.Record类中的List查询这个查询可以从指定journal日志文件中获取日志记录 USER>set rs2=##class(%ResultSet).%New("%SYS.Journal.Record:List") USER>do rs2.Execute("c:\intersystems\cache\mgr\journal\20190620.003") USER>while rs2.Next() { if rs2.Get("GlobalReference")["TEST" write rs2.Get("GlobalReference"),!} ^["^^c:\intersystems\cache\mgr\user\"]TEST(1) ...... ^["^^c:\intersystems\cache\mgr\user\"]TEST(9) ^["^^c:\intersystems\cache\mgr\user\"]TEST(10) 这里我们可以把从A查询获得的结果传到B查询里。如果想了解从B查询里还能获得哪些字段的内容,请参考文档里的%SYS.Journal.Record类定义 下面是一个把A和B查询合并在一起的例子: ///参数 globalname: 需要查询的Global名字(不包括^) ClassMethod SearchAllJournals(globalname As %String) { if $get(globalname)="" { write "请指定Global名字",! quit } //从当前所有journal日志文件中搜索指定的global set rs1=##class(%ResultSet).%New() set rs1.ClassName="%SYS.Journal.File" set rs1.QueryName="ByTimeReverseOrder" do rs1.%Execute() while rs1.%Next() { set jrnfile=rs1.%Get("Name") set size=rs1.%Get("Size") write "Journal file:",jrnfile,!," File size:",size/1024/1024," MB",! do ..SearchGlobal(globalname,jrnfile) } do rs1.Close() } ///第一个参数 globalname: 需要查询的Global名字(不包括^) ///第二个参数 jrnfile: 指定的journal日志文件名字(包括路径) ClassMethod SearchGlobal(globalname As %String, jrnfile As %String) { set rs1=##class(%ResultSet).%New() set rs1.ClassName="%SYS.Journal.Record" set rs1.QueryName="List" //打开journal日志文件并搜索指定的Global do rs1.%Execute(jrnfile,"GlobalReference,NewValue",,,$lb("GlobalReference","[",globalname)) while rs1.%Next() { set glo=rs1.%Get("GlobalReference") write " ",glo," = ",rs1.%Get("NewValue"),! } do rs1.Close() }
公告
Claire Zheng · 八月 22, 2022

InterSystems IRIS医疗版互联互通套件2.0版支持国内互联互通标准转换为FHIR标准,提升数据易用性

2022年8月22日,中国 北京 —— 致力于帮助客户解决最关键的可扩展性、互操作性和速度问题的创新数据技术提供商InterSystems今日宣布在中国推出InterSystems IRIS医疗版互联互通套件2.0版,更好地满足用户对数据利用的需求。医疗技术的进步带来了呈指数级增长的数据量,医疗数据变得更分散、异构性更强、数据量更大,互操作性变得比以往任何时候都更加重要,更具挑战性。在国内,中国医院信息互联互通标准化成熟度测评工作自启动以来,已成为医院数据实现互联互通的重要建设标准。在国际上,HL7 FHIR®(快速医疗互操作性资源)缩小了医疗数据爆炸与数据应用能力之间的差距,成为面向未来的医疗数据互操作的标准。近年来,FHIR引起国内业内人士越来越多的关注与认可。此次推出的InterSystems IRIS医疗版互联互通套件2.0版本打通了国际、国内互联互通生态,有助于推动医疗数据的有效利用。 作为医疗行业数据技术和基于标准的互操作性的领导者,InterSystems长期致力于基于FHIR提供解决方案以解决医疗行业面临的挑战。2021年,InterSystems中国结合国内新版测评标准推出InterSystems IRIS医疗版互联互通套件,满足了医院快速落地互联互通标准化成熟度测评涉及到的标准化改造需求,广受市场认可。点击此处了解“InterSystems IRIS医疗版互联互通套件”详情。 InterSystems最新推出的InterSystems IRIS医疗版互联互通套件2.0版在原有服务基础上,打通了国内互联互通生态与FHIR生态,支持互联互通文档转换为FHIR资源,这一创新举措有效填补了市场空白。通过转换,满足FHIR标准的医疗数据能够在多种业务场景下更易获取和应用。InterSystems IRIS医疗版互联互通套件2.0版解决了长期以来大量医疗数据无法得到有效利用的难题,有利于提升医疗数据的利用价值,助力医疗机构持续实现业务创新。对用户而言,基于InterSystems IRIS医疗版数据平台,即可一键部署FHIR资源仓库,并基于FHIR API和资源开发临床、科研和健康管理等新应用。 此外,InterSystems IRIS医疗版互联互通套件2.0版可为用户提供一套完整的API,实现对互联互通平台的监控和管理,提升用户的业务管理能力。 InterSystems技术兼备高性能与稳定性,在国内连续多年支持数百家大型公立医院海量数据稳定运行。主流PC服务器单实例下,支持日消息吞吐量可高达27.64亿。截至2021年,InterSystems技术已助力一百余家医院通过四级及以上医院信息互联互通标准化成熟度评级,其中,五乙用户占全国30%以上。 InterSystems 亚太区总经理卢侠亮表示:“FHIR能够实时访问分布在各系统、数据库和设备上的数据,因此被行业称为面向未来的医疗数据标准,对于希望有效利用数据价值的用户来说,FHIR是不容错过的。InterSystems多年来始终致力于FHIR建设,我相信InterSystems IRIS医疗版互联互通套件2.0将为中国用户带来更高效的标准化互联互通技术保障。” 2022年8月19日,“InterSystems IRIS医疗版互联互通套件2.0”线上发布会成功举办,会议包括“产品演示”与“互动答疑”两个环节,欢迎点击此处观看发布会回放,了解更多详情。 如果您希望了解更多相关内容,欢迎跟帖回复!
文章
Claire Zheng · 十二月 3, 2021

【视频】InterSystems IRIS医疗版互联互通套件:助力公立医院高效建设互联互通平台

InterSystems面向中国用户推出InterSystems IRIS医疗版互联互通套件,以满足医院信息化建设的标准化要求,促进业务协同,助力公立医院高效建设互联互通平台。
文章
he hf · 四月 24, 2023

SqlDbx连接IRIS攻略new

SqlDbx是我们常用的数据库查询与操作工具,因其轻量且无须安装而无处不在,然而习惯了在Intersystems的CACHE和ENSEMBLE版本下使用SqlDbx在升级到IRIS版本后却无法使用了,为此进行了一系列尝试,并最终获得成功,形成本文攻略,分享给大家。 1、在SqlDbx的连接登录窗口,从DBMS Type中直接选择 “InterSystems CACHE”连接IRIS会报错,提示“通过IRISconnect失败”,说明“InterSystems CACHE”不再适用于IRIS。 2、考虑IRIS的ODBC支持,为此换一种思路,采用ODBC方式连接,此方式需要在ODBC中建立DSN。 3、从Intersystems官网https://intersystems-community.github.io/iris-driver-distribution/或github网站https://github.com/intersystems-community/iris-driver-distribution/tree/...下载InterSystems IRIS ODBC 32位驱动,注意一定要下载32位驱动(注:SqlDbx现只支持32位的ODBC)。 4、下载后直接安装即可。 5、通过Windows的控制面板找到“管理工具”,打开后找到“ODBC Data Sources (32-bit)”(注:SqlDbx现只支持32位的ODBC),在弹出的“ODBC数据源管理程序(32位)”窗口中“用户DSN”页签中选择添加DSN,在随后弹出的“数据源驱动程序”窗口中选择“InterSystems IRIS ODBC35”,点击“完成”。 6、在弹出的“InterSystems ODBC Data Source Setup”窗口中填写数据源名称、描述、主机IP、端口、命名空间、用户名、密码,检查正确无误后、点击测试连接,在弹出的窗口中科室看到连接成功结果,点击“OK”,这就基本成功啦。 7、回到“ODBC数据源管理程序(32位)”窗口,可以看到刚才成功添加的用户DSN。 8、再回到SqlDbx的连接登录窗口,从DBMS Type中选择“OBDC”,点击DSN下拉选择框的后面三个点,在弹出的选择窗口中可以看到刚才成功添加的用户DSN,选中并点击OK,DSN中出现了刚才选择的数据库服务器,点击OK,成功完成了连接登录。恭喜你,可以用SqlDbx继续对IRIS的访问和操作啦! 您可以试试dbeaver dbeaver的兼容也特别好。
文章
Nicky Zhu · 九月 9, 2021

IRIS 2021 技术文档 First Look 22 -- 技术概要:部署 InterSystems 分片集群

本文档将您介绍InterSystems IRIS®数据平台的分片(sharding)功能,以及它在分片集群中的使用,以水平扩展 InterSystems IRIS 的数据量。 作为本指南的一部分,您将使用 ICM 在公共云中提供的分片集群,并了解分片表(sharding a table)如何在集群中的分片之间分布其行。 分片(Sharding)如何帮助您? 您感受到大数据(Big Data)的热度了吗? 无论是否准备好了,我们都在管理比以往任何时候都多的数据,并被要求用这些数据做更多的事情——所需的响应时间也越来越短。无论您是照顾一千万名患者、每天处理数十亿的金融订单,追踪一个星系的恒星,还是监控一千个工厂的引擎,数据平台不仅要支持您目前的数据工作量,而且还必须在保持性能的同时进行扩展(Scale),以满足不断增长的需求,避免业务中断。每个特定业务的工作量对其运行的数据平台提出了不同的挑战 — 而随着工作量的增加,这些挑战将变得更加严峻。 InterSystems IRIS 包含一套全面的功能来扩展(Scale)您的应用程序,这些功能可以单独或组合应用,这取决于您的工作量的性质和它所面临的特定性能挑战。其中之一是分片(sharding),它在多个服务器上对数据及其相关缓存进行分区,为查询和数据摄取提供灵活、价优的性能扩展,同时通过高效的资源利用使基础设施价值最大化。InterSystems IRIS 分片集群(sharded cluster) 可以为各种应用程序提供显著的性能优势,特别是对于那些工作量包括以下一项或多项的应用程序: 高容量或高速数据摄入,或组合。 相对较大的数据集,返回大量数据的查询,或两者兼有。 执行大量数据处理的复杂查询,例如扫描磁盘上的大量数据或涉及大量计算工作的查询。 这些因素各自都会影响分片(sharding)的潜在收益,但如果将它们结合起来,收益可能会得到增强。例如,所有这三个因素的组合——快速摄入的大量数据、大型数据集以及检索和处理大量数据的复杂查询——使得如今的许多分析工作量非常适合进行分片(sharding)。 请注意,这些特征都与数据有关;InterSystems IRIS 分片(sharding)的主要功能是扩展数据量(sharded cluster)。但是,当涉及部分或所有这些数据相关因素的工作量也经历了来自大量用户的非常高的查询量时,分片集群也可以包括扩展用户量(scale for user volume)功能。分片(sharding)也可以与垂直扩展相结合。通过 InterSystems IRIS,您可以为工作量的性能挑战创建恰到好处的整体扩展解决方案。 分片(Sharding)是如何工作的? 分片架构的核心是跨多个系统对数据及其相关缓存进行分区。分片集群将大型数据库表水平(即按行)划分为多个 InterSystems IRIS 实例,称为数据节点(data node),同时允许应用程序通过这些实例中的任何一个访问这些表。每个数据节点在集群分片数据中的份额被称为分片(shard)。这种架构有三个优势: 并行处理(Parallel processing) 查询在数据节点上并行运行,合并查询结果,并作为完整的查询结果返回给应用程序,在许多情况下显著提高了执行速度。 分区缓存(Partitioned caching) 每个数据节点都有自己的专用缓存,而不是由单个实例的缓存为整个数据集服务,这大大降低了缓存溢出和强制降低性能的磁盘读取的风险。 并行加载(Parallel loading) 数据可以并行加载到数据节点上,从而减少摄取工作量和查询工作量之间的缓存和磁盘争夺,提高两者的性能。 一个被称为分片管理器(sharding manager)的联合软件组件会跟踪哪些数据位于哪些数据节点上,并相应地指导查询。非分片数据存储在配置的第一个数据节点上,称为数据节点 1 (它也存储代码和元数据)。从应用程序 SQL 的角度来看,分片表(sharded table)和非分片表(nonsharded table)之间的区别是完全透明的。 图 1: 一个基本的分片集群 试一试!部署和演示 InterSystems IRIS 分片集群 在这次探索中,您将 使用 InterSystems 云管理器(InterSystems Cloud Manager,ICM)在公共云中部署基本的分片集群。 ICM 是一个自动化的命令行工具,可以轻松地在云中配置基础设施,并在提供的节点上部署 InterSystems IRIS 和其他服务。ICM 负责所有需要的 InterSystems IRIS 配置,所以如果您指定了一个分片集群,该集群在部署完成后就可以使用了。 使用不同的分片键(shard key)从相同的数据中创建三个分片表(sharded table),并观察数据节点上跨分片的行的不同分布。 分片键是用来确定分片表的哪些行存储在哪些分片上的一个或多个字段。默认情况下,RowID 被用作分片键,这种分布对于大多数分片表来说是最有效的方法,因为它提供了数据均匀分布的最佳保证,并允许最有效的并行数据加载。然而,在一种情况下,用户定义的键可能是有益的。当您对在字段或用于连接它们的字段上的查询中经常连接的两个大表进行分片时,要连接的行被存储在相同的分片上,并且连接可以在每个分片上本地执行,而不是跨分片执行(across the shard),从而提供显著的性能提升。这被称为 cosharded 连接(cosharded join)。 在所有三个分片表上运行相同的查询,以证明跨分片的行分布对查询是完全透明。 为了向您介绍分片(sharding),而又不至于让您在细节上陷入困境,我们保持了简单的探索。生产中的分片集群需要计划和许多决策,所以确保不要把对分片(sharding)的探索和真实情况相混淆!例如,在设计一个生产集群时,您将检查您的架构和表,以决定哪些表将被分片,然后根据分片数据的预期工作集和服务器上数据库缓存的可用内存量,决定部署多少个数据节点(通常为 4 到 16 个)。然而,在本次探索中,您将部署一个由两个数据节点组成的基本集群。本文档末尾列出的参考资料将使您对生产中使用分片(sharding )的情况有一个很好的了解。Scalability Guide(《可扩展性指南》)中的 "Horizontally Scaling for Data Volume Sharding(《水平扩展数据卷分片[Sharding]》)"一章提供了有关分片(sharding)和分片集群的详细信息。 这些说明假定您有 InterSystems IRIS 分片(sharding)许可证并可以访问 InterSystems 软件下载。 使用 ICM 部署集群 您可以在 First Look:InterSystems Cloud Manager(《技术概要:InterSystems 云管理器》)中找到使用 ICM 在亚马逊网络服务(Amazon Web Services)公共云平台上部署分片集群的程序;特别是在 Try It!Deploy InterSystems IRIS in the Cloud with ICM(试一试!使用 ICM 在云中部署 InterSystems IRIS)部分。您可以使用此处显示的整个程序。当您进入自定义定义.json(Customize definitions.json)时,验证每个 LicenseKey 字段的值是否是 defaults.json 文件中 LicenseDir 字段指定的暂存位置中的 InterSystems IRIS 分片(sharding)许可证的文件名。当您完成了部署阶段(部署 InterSystems IRIS[Deploy InterSystems IRIS])后,留在 ICM 容器中。 注意: 正如 Scalability Guide(《可扩展性指南》)中的 Deploying the Sharded Cluster(部署分片集群) 所描述的那样,您也可以在现有的物理、虚拟或云机器上安装 InterSystems IRIS 实例,并使用分片 API(Sharding API) 或管理门户(Management Portal)部署分片集群,或使用多种方法之一自动化部署分片集群。 使用不同的分片键以不同的方式分布行,然后查询分片表 为了了解分片集群如何根据您使用的分片键(shard key)在数据节点上的分片上对分片表(sharded table)进行分区,您将连接到集群并执行以下步骤: 创建并填充一个小型的非分片表。 使用三个不同的分片键,创建三个与非分片表具有相同字段的分片表 。 从非分片表中填充分片表。 从分片表中选择行,以查看在每种情况下,行在分片(数据节点)上的分布情况。 当一个表被分片时,RowID 值被从每个分片的不同范围分配,从相隔甚远的范围开始;相同范围的行在同一个分片上。当处理一个小表时,就像本例一样,分片的 RowID 很容易区分,清楚地告诉您哪些行在一个分片上,哪些在另一个分片上(尽管您无法分辨哪个分片是哪个)。在 RowID 上分片的表的行的分布方式与行中的数据没有关系,如果您清空并重新加载一个表,可能会有所不同。另一方面,用户定义的分片键,根据键中一个或多个字段的值来分配行,因此当您清空并重新加载表(假设值和分片数没有改变)时将是相同的。 查询所有三个表以获得其中一个字段的最大长度,来显示跨分片(across shards)的行的分布对查询是透明的。 对于这部分探索,请使用以下程序: 为任意一个数据节点实例打开终端(Terminal)窗口。 在 ICM 命令行上, 发出命令 icm session 命令,使用 -machine 选项指定一个数据节点的名称,使用 - namespace 选项指定集群命名空间 IRISCLUSTER (或者使用默认文件中的 Namespace 字段指定的命名空间,如果不同的话)。 如果您不确定节点的名称,可以使用 icm inventory 命令来显示节点名称: $ icm inventory Machine IP Address DNS Name Region Zone Acme-DATA-TEST-0001 00.53.183.209 ec2-00-53-183-209.us-west-1.compute.amazonaws.com us-west-1 c Acme-DATA-TEST-0002 00.53.183.185 ec2-00-53-183-185.us-west-1.compute.amazonaws.com us-west-1 c 选择一个节点(哪个节点并不重要)并发出命令: icm session -machine Acme-DATA-TEST-0002 -namespace IRISCLUSTER icm session 命令为指定节点上的 InterSystems IRIS 实例打开一个终端(Terminal)窗口。 如果您使用 %SYSTEM.Cluster.Sharding API 手动部署您的集群,使用 InterSystems IRIS Basics:Connecting an IDE(《技术概要:连接一个 IDE》)中的procedure described for your instance(为您的实例描述的程序),在任一实例上打开一个终端(Terminal)窗口,然后切换到 IRISCLUSTER 命名空间 (或者初始化集群时指定的命名空间,如果不同的话)。 Node: Acme-DATA-TEST-0002, Instance: IRIS USER>set $namespace="IRISCLUSTER" IRISCLUSTER> 打开终端(Terminal)SQL shell:IRISCLUSTER>do $SYSTEM.SQL.Shell() [SQL]IRISCLUSTER>> 使用以下 SQL 语句,创建并填充非分片表 test.nonsharded。 CREATE TABLE test.nonsharded (field1 CHAR(5), field2 CHAR(5)) INSERT INTO test.nonsharded (field1,field2) VALUES ('one','one') INSERT INTO test.nonsharded (field1,field2) VALUES ('one','two') INSERT INTO test.nonsharded (field1,field2) VALUES ('one','three') INSERT INTO test.nonsharded (field1,field2) VALUES ('two','one') INSERT INTO test.nonsharded (field1,field2) VALUES ('two','two') INSERT INTO test.nonsharded (field1,field2) VALUES ('two','three') INSERT INTO test.nonsharded (field1,field2) VALUES ('three','one') INSERT INTO test.nonsharded (field1,field2) VALUES ('three','two') INSERT INTO test.nonsharded (field1,field2) VALUES ('three','three') 使用 SELECT 来查看表的内容: SELECT * FROM test.nonsharded field1 field2 one one one two one three two one two two two three three one three two three three 使用 test.nonsharded 中的相同字段创建三个分片表,在第一个表中使用默认的分片键(RowID),在第二个表中使用 field1 字段,在第三个表中使用 field2 字段,并使用从 test.nonsharded 中选择的 INSERT INTO 语句填充每一个: CREATE TABLE test.rowid (field1 CHAR(5), field2 CHAR(5), SHARD) INSERT INTO test.rowid (field1,field2) SELECT field1,field2 FROM test.nonsharded CREATE TABLE test.field1 (field1 CHAR(5), field2 CHAR(5), SHARD KEY (field1)) INSERT INTO test.field1 (field1,field2) SELECT field1,field2 FROM test.nonsharded CREATE TABLE test.field2 (field1 CHAR(5), field2 CHAR(5), SHARD KEY (field2)) INSERT INTO test.field2 (field1,field2) SELECT field1,field2 FROM test.nonsharded 使用 SELECT *,%ID 来显示每个分片表的内容和它在分片上的 RowID。 SELECT *,%ID FROM test.rowid ORDER BY %ID field1 field2 ID one one 1 one two 2 two one 3 two two 4 three three 5 one three 256000 two three 256001 three one 256002 three two 256003 这个分布并不反映 field1 或 field2 的值(具有各自全部三个值的行位于两个分片上)。如果您删除、重新创建并重新加载 test.rowid,分布可能会有所不同。 SELECT *,%ID FROM test.field1 ORDER BY %ID field1 one one one field2 one 1 two 2 three 3 ID two one 256000 two two 256001 two three 256002 three one 256003 three two 256004 three three 256005 在 field1 字段上分片(sharding)会分布行,使那些具有相同 field1 值的行被放在同一个分片上。在这种情况下,值为 1 的行在一个分片上,值为 2 和 3 的行在另一个分片上,但是哪个数值最终在哪个分片上取决于有多少个分片和多少个数值。 SELECT *,%ID FROM test.field2 ORDER BY %ID field1 field2 ID one one 1 two one 2 three one 3 one two 256000 one three 256001 two two 256002 two three 256003 three two 256004 three three 256005 这里,分布是由 field2 字段的值决定的。 最后,作为分片如何将工作分配到数据节点的示例,对所有三个分片表使用以下 SELECT 语句: SELECT MAX(LENGTH(field2)) FROM <table> 在每种情况下,结果都是 5,即最长值的长度是 3,因为跨分片的行分布对查询来说是完全透明的。 MAX(LENGTH(field2)) 表达式在每个分片上独立计算,分片管理器选择它们返回结果的 MAX()。例如,当查询在 test.field2 表上运行时,一个分片返回 3,因为它在 field2 字段中只有值 1 ,而另一个分片返回 5;然后分片管理器选择 5 作为两个结果中较大的那个。 如果您愿意,可以使用 EXPLAIN 来显示查询计划,明确指出如何将工作发送到分片上: EXPLAIN SELECT MAX(LENGTH(field2)) FROM <table> 更多分片集群选项 分片集群的其他选项包括如下内容: 您可以随时添加数据节点,并跨扩展的数据节点集重新平衡现有的分片数据。重新平衡(Rebal ancing)不能与查询和更新同时进行,因此只有在分片集群离线并且没有其他分片操作的情况下才能进行。( Scalability Guide[《可扩展性指南》]中的 Add Nodes and Rebalance Data[添加节点和重新平衡数据] ) 要为集群上的数据添加高可用性,您可以将数据节点部署为镜像故障转移对。( Scalability Guide[《可扩展性指南》]中的 Mirror for High Availability[高可用性镜像])。 对于需要极低查询延迟的高级用例(可能与不断涌入的数据相冲突),可以添加计算节点 ,为查询服务提供一个透明的缓存层。当集群包含计算节点时,只读的查询会自动在计算节点上并行执行,而不是在数据节点上执行;所有写入操作(插入、更新、删除和 DDL 操作)继续在数据节点上执行。这种分工将查询和数据摄取工作量分开,同时保持并行处理和分布式缓存的优势,提高两者的性能。(Scalability Guide[《可扩展性指南》]中的 Deploy Compute Nodes[部署计算节点]) 了解有关分片(Sharding)的更多信息 要了解有关分片的更多信息,请参见 Data Platform Scalability Technology Overview(《数据平台可扩展性技术概要》) (视频) Introduction to Sharding(《分片简介》) (在线课程) Sharding Basics(《分片基础》) (在线课程) Experience InterSystems IRIS in the Cloud(在云中体验 InterSystems IRIS) (在线体验) Scalability Guide(《可扩展性指南》) First Look:InterSystems Cloud Manager(《技术概要:InterSystems 云管理器》)
文章
Jingwei Wang · 九月 28, 2021

IRIS 2021 技术文档 First Look 16 Java 网关(Gateway)和InterSystems 产品

本文档介绍了如何在 InterSystems IRIS®数据平台中使用 Java 网关(Gateway)与 Java 组件进行互操作。在本文中,您将首先创建一个示例 JAR 文件。然后,您将在 InterSystems IRIS 管理门户(Management Portal)中创建并启动 Java 网关(Gateway)。您将以编程方式导入创建的示例 JAR 文件。最后,您将在 ObjectScript 中创建并操作一些代理类(proxy class)和对象(object)。 为了让您体验 Java 网关(Gateway ),而又不陷入细节困境,我们保持了简单的探索。这些活动被设计成只使用默认设置和功能,这样您就可以熟悉功能的基本原理,而不必处理那些离题或过于复杂的细节。当您把 Java 网关(Gateway)引入您的生产系统时,您可能需要做一些不同的事情。请确保不要把这种对 Java 网关(Gateway )的探索与真实的情况相混淆!本文档末尾提供的参考资料将使您对在生产中使用 Java 网关(Gateway)的情况有一个很好的了解。 要浏览所有的技术概要(First Look),包括下面描述的可以在免费的社区版(Community Edition)实例上执行的那些,请参见 InterSystems 技术概要。 为什么 Java 网关(Gateway)很重要 Java 网关(Gateway)为 InterSystems IRIS 与 Java 组件进行互操作提供了一种简单的方法。在使用 Java 网关(Gateway)导入 JAR 文件后,您可以实例化一个外部 Java 对象,并将其作为 InterSystems IRIS 中的本机对象进行操作。您可以从 InterSystems IRIS 和 ObjectScript 内部访问 Java 类和方法! 在内部,Java 网关(Gateway)为每个 Java 类生成一对一的 ObjectScript 代理。通常,使用 Java 网关(Gateway)的最佳方法是构建一个小型 Java 封装类(wrapper class),它只公开您想要的功能,然后为这个封装创建一个代理。 探索 Java 网关(Gateway) 我们开发了一个简短的演示,向您展示如何使用 Java 网关(Gateway)和 InterSystems IRIS。想试试InterSystems IRIS Java 开发和互操作性功能的在线视频演示吗?请查看 Java QuickStart(Java 快速入门)! 用前须知 要使用该程序,您需要在一个系统上工作,应安装 JDK 1.8 版本和您选择的 Java IDE,并连接一个正在运行的 InterSystems IRIS 实例。您对 InterSystems IRIS 的选择包括多种已授权的和免费的评估实例;实例不需要由您正在工作的系统托管(尽管它们必须相互具有网络访问权限)。关于如何部署每种类型的实例的信息(如果您还没有可使用的实例),请参见InterSystems IRIS 基础:连接一个 IDE中的部署 InterSystems IRIS。使用同一文档中的InterSystems IRIS 连接信息和 Java IDE中的信息,将 IDE 连接到您的 InterSystems IRIS 实例。 创建 JAR 文件 使用您选择的 IDE 在 Java 中创建 Person 类。使用以下示例代码: public class Person { public int age; public String name; //constructor public Person (int startAge, String Name) { age = startAge; name = Name; } public void setAge(int newAge) { age = newAge; } public String getName() { return name; } public int getAge() { return age; } public static void main(String []args) { Person myPerson = new Person (5, "Tom"); System.out.println(myPerson.getName()); System.out.println(myPerson.getAge()); }} 编译 Person 类。然后,打开命令提示符(Command Prompt)窗口,并导航到包含 Person.class 文件的目录。使用下面的命令来生成 Person.jar 文件: jar cf Person.jar Person.class 注意文件的位置。 启动 Java 网关(Gateway) 要启动 Java 网关(Gateway),请按照以下步骤操作: 使用InterSystems IRIS 基础:连接一个 IDE中为您的实例描述的 URL,在浏览器中打开您的实例的管理门户(Management Portal)。 导航到 Object Gateways(对象网关)页面。(System Administration(系统管理) > Configuration(配置) > Connectivity(连接) > External Language Servers 选择 Create New External Language Servers 下拉菜单选择 Java 。 服务器名称输入 JavaGatewayTest,端口输入 55555。 点击 Save(保存)。 在新的 Java 网关(Gateway)所在行中,点击 Start(开始)。 生成代理类(Proxy Classes) 在 USER 命名空间(或您在已安装的实例)中创建一个名为 CreateProxyClasses.cls 的新 ObjectScript 类,包名为 JavaGatewayTest。粘贴以下代码,用您的 InterSystems IRIS 实例的连接信息 (如InterSystems IRIS 基础:连接一个 IDE中所述)替换 gwyConn.&Connect 的参数。您可以指定所示的 USER 命名空间,也可以选择实例上创建的另一个命名空间。用双引号括起来的 Person.jar 文件的完整文件路径替换 YOUR FILEPATH HERE。 Class JavaGatewayTest.CreateProxyClasses Extends %Persistent { ClassMethod run() { // get a connection to the Java Gateway set gwyConn = ##class(%Net.Remote.Gateway).%New() set status = gwyConn.%Connect("127.0.0.1", 55555, "USER") if $$$ISERR(status) { write !,"error: "_$system.OBJ.DisplayError(status) quit } // add the jar to the classpath set classpath = ##class(%ListOfDataTypes).%New() do classpath.Insert("YOUR FILEPATH HERE") set status = gwyConn.%AddToCurrentClassPath(classpath) if $$$ISERR(status) { write !,"error: "_$system.OBJ.DisplayError(status) quit } // create the proxy ObjectScript classes that correspond to the Java classes in the jar file set status = gwyConn.%Import("Person",,,,1) if $$$ISERR(status) { write !,"error: "_$system.OBJ.DisplayError(status) quit } // close the connection to the Java gateway set status = gwyConn.%Disconnect() if $$$ISERR(status) { write !,"error: "_$system.OBJ.DisplayError(status) quit }}} 编译并构建该类。 打开 InterSystems 终端(Terminal),并导航到您指定的命名空间。使用以下命令执行 run() 方法: do ##class(JavaGatewayTest.ManipulateObjects).run() 您应该可以看到以下输出: Name: Tom Age: 5 setting age to 100 Age: 100 现在您已经成功地完成了练习,停止您创建的 Java 网关(Gateway)。返回到管理门户(Management Portal)中的 External Language Servers页面,找到您的 JavaGatewayTest 网关,并选择 Stop(停止)。 了解有关 Java 网关(Gateway)的更多信息 要了解有关 Java 网关(Gateway)和 InterSystems IRIS 的更多信息,请参见: 使用 Java 网关(Gateway) 有个疑问,生成代理类(Proxy Classes)该步骤中是不是应该体现为JavaGateway而不是Net.Remote.Gateway。 %Net.Remote.Gateway 是 %Net.Remote.Java.JavaGateway的基类,是用来建立JavaGateway的连接使用的。
文章
Jeff Liu · 九月 23, 2021

IRIS 2021 技术文档 First Look 19 使用 InterSystems 产品优化 SQL 性能

html {overflow-x: initial !important;}:root { --bg-color: #ffffff; --text-color: #333333; --select-text-bg-color: #B5D6FC; --select-text-font-color: auto; --monospace: "Lucida Console",Consolas,"Courier",monospace; --title-bar-height: 20px; } .mac-os-11 { --title-bar-height: 28px; } html { font-size: 14px; background-color: var(--bg-color); color: var(--text-color); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; } body { margin: 0px; padding: 0px; height: auto; inset: 0px; font-size: 1rem; line-height: 1.42857143; overflow-x: hidden; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; tab-size: 4; background-position: inherit; background-repeat: inherit; } iframe { margin: auto; } a.url { word-break: break-all; } a:active, a:hover { outline: 0px; } .in-text-selection, ::selection { text-shadow: none; background: var(--select-text-bg-color); color: var(--select-text-font-color); } #write { margin: 0px auto; height: auto; width: inherit; word-break: normal; word-wrap: break-word; position: relative; white-space: normal; overflow-x: visible; padding-top: 36px; } #write.first-line-indent p { text-indent: 2em; } #write.first-line-indent li p, #write.first-line-indent p * { text-indent: 0px; } #write.first-line-indent li { margin-left: 2em; } .for-image #write { padding-left: 8px; padding-right: 8px; } body.typora-export { padding-left: 30px; padding-right: 30px; } .typora-export .footnote-line, .typora-export li, .typora-export p { white-space: pre-wrap; } .typora-export .task-list-item input { pointer-events: none; } @media screen and (max-width: 500px) { body.typora-export { padding-left: 0px; padding-right: 0px; } #write { padding-left: 20px; padding-right: 20px; } .CodeMirror-sizer { margin-left: 0px !important; } .CodeMirror-gutters { display: none !important; } } #write li > figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max-width: 100%; vertical-align: middle; image-orientation: from-image; } button, input, select, textarea { color: inherit; font-family: inherit; font-size: inherit; font-style: inherit; font-variant-caps: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; } input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; } *, ::after, ::before { box-sizing: border-box; } #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p, #write pre { width: inherit; } #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write p { position: relative; } p { line-height: inherit; } h1, h2, h3, h4, h5, h6 { break-after: avoid-page; break-inside: avoid; orphans: 4; } p { orphans: 4; } h1 { font-size: 2rem; } h2 { font-size: 1.8rem; } h3 { font-size: 1.6rem; } h4 { font-size: 1.4rem; } h5 { font-size: 1.2rem; } h6 { font-size: 1rem; } .md-math-block, .md-rawblock, h1, h2, h3, h4, h5, h6, p { margin-top: 1rem; margin-bottom: 1rem; } .hidden { display: none; } .md-blockmeta { color: rgb(204, 204, 204); font-weight: 700; font-style: italic; } a { cursor: pointer; } sup.md-footnote { padding: 2px 4px; background-color: rgba(238, 238, 238, 0.7); color: rgb(85, 85, 85); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; cursor: pointer; } sup.md-footnote a, sup.md-footnote a:hover { color: inherit; text-transform: inherit; text-decoration: inherit; } #write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; } figure { overflow-x: auto; margin: 1.2em 0px; max-width: calc(100% + 16px); padding: 0px; } figure > table { margin: 0px; } tr { break-inside: avoid; break-after: auto; } thead { display: table-header-group; } table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; break-inside: auto; text-align: left; } table.md-table td { min-width: 32px; } .CodeMirror-gutters { border-right-width: 0px; background-color: inherit; } .CodeMirror-linenumber { } .CodeMirror { text-align: left; } .CodeMirror-placeholder { opacity: 0.3; } .CodeMirror pre { padding: 0px 4px; } .CodeMirror-lines { padding: 0px; } div.hr:focus { cursor: none; } #write pre { white-space: pre-wrap; } #write.fences-no-line-wrapping pre { white-space: pre; } #write pre.ty-contain-cm { white-space: normal; } .CodeMirror-gutters { margin-right: 4px; } .md-fences { font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; overflow: visible; white-space: pre; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; position: relative !important; background-position: inherit; background-repeat: inherit; } .md-fences-adv-panel { width: 100%; margin-top: 10px; text-align: center; padding-top: 0px; padding-bottom: 8px; overflow-x: auto; } #write .md-fences.mock-cm { white-space: pre-wrap; } .md-fences.md-fences-with-lineno { padding-left: 0px; } #write.fences-no-line-wrapping .md-fences.mock-cm { white-space: pre; overflow-x: auto; } .md-fences.mock-cm.md-fences-with-lineno { padding-left: 8px; } .CodeMirror-line, twitterwidget { break-inside: avoid; } .footnotes { opacity: 0.8; font-size: 0.9rem; margin-top: 1em; margin-bottom: 1em; } .footnotes + .footnotes { margin-top: 0px; } .md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; text-decoration: none; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; line-height: normal; font-weight: 400; text-align: left; box-sizing: content-box; direction: ltr; background-position: 0px 0px; } li div { padding-top: 0px; } blockquote { margin: 1rem 0px; } li .mathjax-block, li p { margin: 0.5rem 0px; } li blockquote { margin: 1rem 0px; } li { margin: 0px; position: relative; } blockquote > :last-child { margin-bottom: 0px; } blockquote > :first-child, li > :first-child { margin-top: 0px; } .footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; white-space: normal; } #write .footnote-line { white-space: pre-wrap; } @media print { body, html { border: 1px solid transparent; height: 99%; break-after: avoid; break-before: avoid; font-variant-ligatures: no-common-ligatures; } #write { margin-top: 0px; padding-top: 0px; border-color: transparent !important; } .typora-export * { -webkit-print-color-adjust: exact; } .typora-export #write { break-after: avoid; } .typora-export #write::after { height: 0px; } .is-mac table { break-inside: avoid; } .typora-export-show-outline .typora-export-sidebar { display: none; } } .footnote-line { margin-top: 0.714em; font-size: 0.7em; } a img, img a { cursor: pointer; } pre.md-meta-block { font-size: 0.8rem; min-height: 0.8rem; white-space: pre-wrap; background-color: rgb(204, 204, 204); display: block; overflow-x: hidden; } p > .md-image:only-child:not(.md-img-error) img, p > img:only-child { display: block; margin: auto; } #write.first-line-indent p > .md-image:only-child:not(.md-img-error) img { left: -2em; position: relative; } p > .md-image:only-child { display: inline-block; width: 100%; } #write .MathJax_Display { margin: 0.8em 0px 0px; } .md-math-block { width: 100%; } .md-math-block:not(:empty)::after { display: none; } .MathJax_ref { fill: currentcolor; } [contenteditable="true"]:active, [contenteditable="true"]:focus, [contenteditable="false"]:active, [contenteditable="false"]:focus { outline: 0px; box-shadow: none; } .md-task-list-item { position: relative; list-style-type: none; } .task-list-item.md-task-list-item { padding-left: 0px; } .md-task-list-item > input { position: absolute; top: 0px; left: 0px; margin-left: -1.2em; margin-top: calc(1em - 10px); border: none; } .math { font-size: 1rem; } .md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; } .md-toc-content { position: relative; margin-left: 0px; } .md-toc-content::after, .md-toc::after { display: none; } .md-toc-item { display: block; color: rgb(65, 131, 196); } .md-toc-item a { text-decoration: none; } .md-toc-inner:hover { text-decoration: underline; } .md-toc-inner { display: inline-block; cursor: pointer; } .md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: 700; } .md-toc-h2 .md-toc-inner { margin-left: 2em; } .md-toc-h3 .md-toc-inner { margin-left: 4em; } .md-toc-h4 .md-toc-inner { margin-left: 6em; } .md-toc-h5 .md-toc-inner { margin-left: 8em; } .md-toc-h6 .md-toc-inner { margin-left: 10em; } @media screen and (max-width: 48em) { .md-toc-h3 .md-toc-inner { margin-left: 3.5em; } .md-toc-h4 .md-toc-inner { margin-left: 5em; } .md-toc-h5 .md-toc-inner { margin-left: 6.5em; } .md-toc-h6 .md-toc-inner { margin-left: 8em; } } a.md-toc-inner { font-size: inherit; font-style: inherit; font-weight: inherit; line-height: inherit; } .footnote-line a:not(.reversefootnote) { color: inherit; } .md-attr { display: none; } .md-fn-count::after { content: "."; } code, pre, samp, tt { font-family: var(--monospace); } kbd { margin: 0px 0.1em; padding: 0.1em 0.6em; font-size: 0.8em; color: rgb(36, 39, 41); background-color: rgb(255, 255, 255); border: 1px solid rgb(173, 179, 185); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; box-shadow: rgba(12, 13, 14, 0.2) 0px 1px 0px, rgb(255, 255, 255) 0px 0px 0px 2px inset; white-space: nowrap; vertical-align: middle; } .md-comment { color: rgb(162, 127, 3); opacity: 0.8; font-family: var(--monospace); } code { text-align: left; } a.md-print-anchor { white-space: pre !important; border: none !important; display: inline-block !important; position: absolute !important; width: 1px !important; right: 0px !important; outline: 0px !important; text-shadow: initial !important; background-position: 0px 0px !important; } .os-windows.monocolor-emoji .md-emoji { font-family: "Segoe UI Symbol", sans-serif; } .md-diagram-panel > svg { max-width: 100%; } [lang="flow"] svg, [lang="mermaid"] svg { max-width: 100%; height: auto; } [lang="mermaid"] .node text { font-size: 1rem; } table tr th { border-bottom-width: 0px; } video { max-width: 100%; display: block; margin: 0px auto; } iframe { max-width: 100%; width: 100%; border: none; } .highlight td, .highlight tr { border: 0px; } mark { background-color: rgb(255, 255, 0); color: rgb(0, 0, 0); } .md-html-inline .md-plain, .md-html-inline strong, mark .md-inline-math, mark strong { color: inherit; } .md-expand mark .md-meta { opacity: 0.3 !important; } mark .md-meta { color: rgb(0, 0, 0); } @media print { .typora-export h1, .typora-export h2, .typora-export h3, .typora-export h4, .typora-export h5, .typora-export h6 { break-inside: avoid; } } .md-diagram-panel .messageText { stroke: none !important; } .md-diagram-panel .start-state { fill: var(--node-fill); } .md-diagram-panel .edgeLabel rect { opacity: 1 !important; } .md-require-zoom-fix { height: auto; margin-top: 16px; margin-bottom: 16px; } .md-require-zoom-fix foreignObject { font-size: var(--mermaid-font-zoom); } .md-fences.md-fences-math { font-size: 1em; } .md-fences-advanced:not(.md-focus) { padding: 0px; white-space: nowrap; border: 0px; } .md-fences-advanced:not(.md-focus) { background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit; background-repeat: inherit; } .typora-export-show-outline .typora-export-content { max-width: 1440px; margin: auto; display: flex; flex-direction: row; } .typora-export-sidebar { width: 300px; font-size: 0.8rem; margin-top: 80px; margin-right: 18px; } .typora-export-show-outline #write { --webkit-flex: 2; flex: 2 1 0%; } .typora-export-sidebar .outline-content { position: fixed; top: 0px; max-height: 100%; overflow: hidden auto; padding-bottom: 30px; padding-top: 60px; width: 300px; } @media screen and (max-width: 1024px) { .typora-export-sidebar, .typora-export-sidebar .outline-content { width: 240px; } } @media screen and (max-width: 800px) { .typora-export-sidebar { display: none; } } .outline-content li, .outline-content ul { margin-left: 0px; margin-right: 0px; padding-left: 0px; padding-right: 0px; list-style: none; } .outline-content ul { margin-top: 0px; margin-bottom: 0px; } .outline-content strong { font-weight: 400; } .outline-expander { width: 1rem; height: 1.428571429rem; position: relative; display: table-cell; vertical-align: middle; cursor: pointer; padding-left: 4px; } .outline-expander::before { content: ''; position: relative; font-family: Ionicons; display: inline-block; font-size: 8px; vertical-align: middle; } .outline-item { padding-top: 3px; padding-bottom: 3px; cursor: pointer; } .outline-expander:hover::before { content: ''; } .outline-h1 > .outline-item { padding-left: 0px; } .outline-h2 > .outline-item { padding-left: 1em; } .outline-h3 > .outline-item { padding-left: 2em; } .outline-h4 > .outline-item { padding-left: 3em; } .outline-h5 > .outline-item { padding-left: 4em; } .outline-h6 > .outline-item { padding-left: 5em; } .outline-label { cursor: pointer; display: table-cell; vertical-align: middle; text-decoration: none; color: inherit; } .outline-label:hover { text-decoration: underline; } .outline-item:hover { border-color: rgb(245, 245, 245); background-color: var(--item-hover-bg-color); } .outline-item:hover { margin-left: -28px; margin-right: -28px; border-left-width: 28px; border-left-style: solid; border-left-color: transparent; border-right-width: 28px; border-right-style: solid; border-right-color: transparent; } .outline-item-single .outline-expander::before, .outline-item-single .outline-expander:hover::before { display: none; } .outline-item-open > .outline-item > .outline-expander::before { content: ''; } .outline-children { display: none; } .info-panel-tab-wrapper { display: none; } .outline-item-open > .outline-children { display: block; } .typora-export .outline-item { padding-top: 1px; padding-bottom: 1px; } .typora-export .outline-item:hover { margin-right: -8px; border-right-width: 8px; border-right-style: solid; border-right-color: transparent; } .typora-export .outline-expander::before { content: "+"; font-family: inherit; top: -1px; } .typora-export .outline-expander:hover::before, .typora-export .outline-item-open > .outline-item > .outline-expander::before { content: '−'; } .typora-export-collapse-outline .outline-children { display: none; } .typora-export-collapse-outline .outline-item-open > .outline-children, .typora-export-no-collapse-outline .outline-children { display: block; } .typora-export-no-collapse-outline .outline-expander::before { content: "" !important; } .typora-export-show-outline .outline-item-active > .outline-item .outline-label { font-weight: 700; } .md-inline-math-container mjx-container { zoom: 0.95; } .CodeMirror { height: auto; } .CodeMirror.cm-s-inner { background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit; background-repeat: inherit; } .CodeMirror-scroll { overflow: auto hidden; z-index: 3; } .CodeMirror-gutter-filler, .CodeMirror-scrollbar-filler { background-color: rgb(255, 255, 255); } .CodeMirror-gutters { border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; white-space: nowrap; background-position: inherit; background-repeat: inherit; } .CodeMirror-linenumber { padding: 0px 3px 0px 5px; text-align: right; color: rgb(153, 153, 153); } .cm-s-inner .cm-keyword { color: rgb(119, 0, 136); } .cm-s-inner .cm-atom, .cm-s-inner.cm-atom { color: rgb(34, 17, 153); } .cm-s-inner .cm-number { color: rgb(17, 102, 68); } .cm-s-inner .cm-def { color: rgb(0, 0, 255); } .cm-s-inner .cm-variable { color: rgb(0, 0, 0); } .cm-s-inner .cm-variable-2 { color: rgb(0, 85, 170); } .cm-s-inner .cm-variable-3 { color: rgb(0, 136, 85); } .cm-s-inner .cm-string { color: rgb(170, 17, 17); } .cm-s-inner .cm-property { color: rgb(0, 0, 0); } .cm-s-inner .cm-operator { color: rgb(152, 26, 26); } .cm-s-inner .cm-comment, .cm-s-inner.cm-comment { color: rgb(170, 85, 0); } .cm-s-inner .cm-string-2 { color: rgb(255, 85, 0); } .cm-s-inner .cm-meta { color: rgb(85, 85, 85); } .cm-s-inner .cm-qualifier { color: rgb(85, 85, 85); } .cm-s-inner .cm-builtin { color: rgb(51, 0, 170); } .cm-s-inner .cm-bracket { color: rgb(153, 153, 119); } .cm-s-inner .cm-tag { color: rgb(17, 119, 0); } .cm-s-inner .cm-attribute { color: rgb(0, 0, 204); } .cm-s-inner .cm-header, .cm-s-inner.cm-header { color: rgb(0, 0, 255); } .cm-s-inner .cm-quote, .cm-s-inner.cm-quote { color: rgb(0, 153, 0); } .cm-s-inner .cm-hr, .cm-s-inner.cm-hr { color: rgb(153, 153, 153); } .cm-s-inner .cm-link, .cm-s-inner.cm-link { color: rgb(0, 0, 204); } .cm-negative { color: rgb(221, 68, 68); } .cm-positive { color: rgb(34, 153, 34); } .cm-header, .cm-strong { font-weight: 700; } .cm-del { text-decoration: line-through; } .cm-em { font-style: italic; } .cm-link { text-decoration: underline; } .cm-error { color: red; } .cm-invalidchar { color: red; } .cm-constant { color: rgb(38, 139, 210); } .cm-defined { color: rgb(181, 137, 0); } div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); } div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); } .cm-s-inner .CodeMirror-activeline-background { background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit; background-repeat: inherit; } .CodeMirror { position: relative; overflow: hidden; } .CodeMirror-scroll { height: 100%; outline: 0px; position: relative; box-sizing: content-box; background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; background-position: inherit; background-repeat: inherit; } .CodeMirror-sizer { position: relative; } .CodeMirror-gutter-filler, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-vscrollbar { position: absolute; z-index: 6; display: none; outline: 0px; } .CodeMirror-vscrollbar { right: 0px; top: 0px; overflow: hidden; } .CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow: auto hidden; } .CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; } .CodeMirror-gutter-filler { left: 0px; bottom: 0px; } .CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 10px; z-index: 3; overflow-y: hidden; } .CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; } .CodeMirror-gutter-wrapper { position: absolute; z-index: 4; border: none !important; background-position: 0px 0px !important; } .CodeMirror-gutter-background { position: absolute; top: 0px; bottom: 0px; z-index: 4; } .CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; } .CodeMirror-lines { cursor: text; } .CodeMirror pre { border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-width: 0px; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; word-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; background-position: 0px 0px; } .CodeMirror-wrap pre { word-wrap: break-word; white-space: pre-wrap; word-break: normal; } .CodeMirror-code pre { border-right-width: 30px; border-right-style: solid; border-right-color: transparent; width: fit-content; } .CodeMirror-wrap .CodeMirror-code pre { border-right-style: none; width: auto; } .CodeMirror-linebackground { position: absolute; inset: 0px; z-index: 0; } .CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; } .CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; } .CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; } .CodeMirror-measure pre { position: static; } .CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right-style: none; width: 0px; } .CodeMirror div.CodeMirror-cursor { visibility: hidden; } .CodeMirror-focused div.CodeMirror-cursor { visibility: inherit; } .cm-searching { background-color: rgba(255, 255, 0, 0.4); } span.cm-underlined { text-decoration: underline; } span.cm-strikethrough { text-decoration: line-through; } .cm-tw-syntaxerror { color: rgb(255, 255, 255); background-color: rgb(153, 0, 0); } .cm-tw-deleted { text-decoration: line-through; } .cm-tw-header5 { font-weight: 700; } .cm-tw-listitem:first-child { padding-left: 10px; } .cm-tw-box { border-style: solid; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-color: inherit; border-top-width: 0px !important; } .cm-tw-underline { text-decoration: underline; } @media print { .CodeMirror div.CodeMirror-cursor { visibility: hidden; } } :root { --side-bar-bg-color: #fafafa; --control-text-color: #777; } @include-when-export url(https://fonts.loli.net/css?family=Open+Sans:400italic,700italic,700,400&subset=latin,latin-ext); /* open-sans-regular - latin-ext_latin */ /* open-sans-italic - latin-ext_latin */ /* open-sans-700 - latin-ext_latin */ /* open-sans-700italic - latin-ext_latin */ html { font-size: 16px; -webkit-font-smoothing: antialiased; } body { font-family: "Open Sans","Clear Sans", "Helvetica Neue", Helvetica, Arial, 'Segoe UI Emoji', sans-serif; color: rgb(51, 51, 51); line-height: 1.6; } #write { max-width: 860px; margin: 0 auto; padding: 30px; padding-bottom: 100px; } @media only screen and (min-width: 1400px) { #write { max-width: 1024px; } } @media only screen and (min-width: 1800px) { #write { max-width: 1200px; } } #write > ul:first-child, #write > ol:first-child{ margin-top: 30px; } a { color: #4183C4; } h1, h2, h3, h4, h5, h6 { position: relative; margin-top: 1rem; margin-bottom: 1rem; font-weight: bold; line-height: 1.4; cursor: text; } h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor { text-decoration: none; } h1 tt, h1 code { font-size: inherit; } h2 tt, h2 code { font-size: inherit; } h3 tt, h3 code { font-size: inherit; } h4 tt, h4 code { font-size: inherit; } h5 tt, h5 code { font-size: inherit; } h6 tt, h6 code { font-size: inherit; } h1 { font-size: 2.25em; line-height: 1.2; border-bottom: 1px solid #eee; } h2 { font-size: 1.75em; line-height: 1.225; border-bottom: 1px solid #eee; } /*@media print { .typora-export h1, .typora-export h2 { border-bottom: none; padding-bottom: initial; } .typora-export h1::after, .typora-export h2::after { content: ""; display: block; height: 100px; margin-top: -96px; border-top: 1px solid #eee; } }*/ h3 { font-size: 1.5em; line-height: 1.43; } h4 { font-size: 1.25em; } h5 { font-size: 1em; } h6 { font-size: 1em; color: #777; } p, blockquote, ul, ol, dl, table{ margin: 0.8em 0; } li>ol, li>ul { margin: 0 0; } hr { height: 2px; padding: 0; margin: 16px 0; background-color: #e7e7e7; border: 0 none; overflow: hidden; box-sizing: content-box; } li p.first { display: inline-block; } ul, ol { padding-left: 30px; } ul:first-child, ol:first-child { margin-top: 0; } ul:last-child, ol:last-child { margin-bottom: 0; } blockquote { border-left: 4px solid #dfe2e5; padding: 0 15px; color: #777777; } blockquote blockquote { padding-right: 0; } table { padding: 0; word-break: initial; } table tr { border: 1px solid #dfe2e5; margin: 0; padding: 0; } table tr:nth-child(2n), thead { background-color: #f8f8f8; } table th { font-weight: bold; border: 1px solid #dfe2e5; border-bottom: 0; margin: 0; padding: 6px 13px; } table td { border: 1px solid #dfe2e5; margin: 0; padding: 6px 13px; } table th:first-child, table td:first-child { margin-top: 0; } table th:last-child, table td:last-child { margin-bottom: 0; } .CodeMirror-lines { padding-left: 4px; } .code-tooltip { box-shadow: 0 1px 1px 0 rgba(0,28,36,.3); border-top: 1px solid #eef2f2; } .md-fences, code, tt { border: 1px solid #e7eaed; background-color: #f8f8f8; border-radius: 3px; padding: 0; padding: 2px 4px 0px 4px; font-size: 0.9em; } code { background-color: #f3f4f4; padding: 0 2px 0 2px; } .md-fences { margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; } .md-task-list-item > input { margin-left: -1.3em; } @media print { html { font-size: 13px; } table, pre { page-break-inside: avoid; } pre { word-wrap: break-word; } } .md-fences { background-color: #f8f8f8; } #write pre.md-meta-block { padding: 1rem; font-size: 85%; line-height: 1.45; background-color: #f7f7f7; border: 0; border-radius: 3px; color: #777777; margin-top: 0 !important; } .mathjax-block>.code-tooltip { bottom: .375rem; } .md-mathjax-midline { background: #fafafa; } #write>h3.md-focus:before{ left: -1.5625rem; top: .375rem; } #write>h4.md-focus:before{ left: -1.5625rem; top: .285714286rem; } #write>h5.md-focus:before{ left: -1.5625rem; top: .285714286rem; } #write>h6.md-focus:before{ left: -1.5625rem; top: .285714286rem; } .md-image>.md-meta { /*border: 1px solid #ddd;*/ border-radius: 3px; padding: 2px 0px 0px 4px; font-size: 0.9em; color: inherit; } .md-tag { color: #a7a7a7; opacity: 1; } .md-toc { margin-top:20px; padding-bottom:20px; } .sidebar-tabs { border-bottom: none; } #typora-quick-open { border: 1px solid #ddd; background-color: #f8f8f8; } #typora-quick-open-item { background-color: #FAFAFA; border-color: #FEFEFE #e5e5e5 #e5e5e5 #eee; border-style: solid; border-width: 1px; } /** focus mode */ .on-focus-mode blockquote { border-left-color: rgba(85, 85, 85, 0.12); } header, .context-menu, .megamenu-content, footer{ font-family: "Segoe UI", "Arial", sans-serif; } .file-node-content:hover .file-node-icon, .file-node-content:hover .file-node-open-state{ visibility: visible; } .mac-seamless-mode #typora-sidebar { background-color: #fafafa; background-color: var(--side-bar-bg-color); } .md-lang { color: #b4654d; } /*.html-for-mac { --item-hover-bg-color: #E6F0FE; }*/ #md-notification .btn { border: 0; } .dropdown-menu .divider { border-color: #e5e5e5; opacity: 0.4; } .ty-preferences .window-content { background-color: #fafafa; } .ty-preferences .nav-group-item.active { color: white; background: #999; } .menu-item-container a.menu-style-btn { background-color: #f5f8fa; background-image: linear-gradient( 180deg , hsla(0, 0%, 100%, 0.8), hsla(0, 0%, 100%, 0)); } :root {--mermaid-font-zoom:1em ;} @media print { @page {margin: 0 0 0 0;} body.typora-export {padding-left: 0; padding-right: 0;} #write {padding:0;}} 技术概要:使用 InterSystems 产品优化 SQL 性能使用 InterSystems SQL 优化查询使用 EXPLAIN 关键字显示查询计划在管理门户(Management Portal)中使用 SQL 查询接口显示查询计划发现查询计划结果中潜在的性能问题测试查询执行测试位片索引(Bitslice Index)的效果向交易类型字段(TransactionType Field)添加位图索引(Bitmap Index)重新测试查询性能查看随时间变化的查询性能了解有关 InterSystems SQL 的更多信息介绍材料 技术概要:使用 InterSystems 产品优化 SQL 性能 技术概要:使用 InterSystems 产品优化 SQL 性能 本技术概要(First Look)指南向您介绍了 InterSystems SQL 查询优化,包括查询分析工具的使用,几种索引方法以及随着时间的变化查看运行时统计数据的能力。 要浏览所有的技术概要(First Look),包括其他可以在免费的云实例或 web 实例上执行的技术概要(First Look),请参见 InterSystems First Looks(《InterSystems 技术概要》)。 使用 InterSystems SQL 优化查询 InterSystems IRIS®数据平台为 SQL 查询性能调整提供全套工具: 查询计划分析的图形化显示 如位图和位片索引(bitslice index)等索引策略结构紧凑,可由矢量化 CPU 指令有效处理。每种索引类型都为某些查询类型(如逻辑条件、计数和聚合函数)提供了好处。通过索引,您可以在一个核心上实现每秒多达数十亿行的查询性能结果。 随时间变化的 SQL 查询性能指标 重要提示: 下面演示中显示的查询性能数字代表了在一台 Windows 10 笔记本电脑上进行的多次演示试验。根据您的环境,您可能会看到不同的查询性能数字。 想查看 InterSystems IRIS SQL 功能快速演示吗?请查看 SQL QuickStart(SQL 快速入门)! 用前须知 阅读本文之前,建议阅读并完成 First Look:InterSystems SQL(《技术概要:InterSystems SQL》)。在这里,您将再次使用 InterSystems IRIS SQL Shell;您将使用的数据来自您在技术概要:InterSystems SQL的演示时创建的百万记录股票交易数据表。 您还将运行 TuneTableutility,它检查表中的数据并创建 InterSystems SQL 查询优化器(决定如何最好地运行任何查询的引擎)使用的统计数据。这些统计数据包括表的大小(区段大小)和每列唯一值的数量(选择性)。优化器在决定连接顺序等情况下使用表大小,其中最好从较小的表开始。在表有多个索引的情况下,选择性有助于优化器选择最佳索引。在产品实例中,您通常只运行一次 TuneTable:在数据被加载到表中之后和运行之前。 演示:显示和解释优化前的查询计划 First Look:InterSystems SQL (《技术概要:InterSystems SQL》)解释了如何执行在技术概要(First Look)和此处运行演示所需的以下步骤: 选择一个 InterSystems IRIS 实例。您的选择包括多种类型的已授权的和免费的评估实例;关于如何部署每种类型的信息,请参见 InterSystems IRIS Basics: Connecting an IDE(《InterSystems IRIS 基础:连接一个 IDE》)中的 Deploying InterSystems IRIS(部署 InterSystems IRIS)。 打开 InterSystems 终端(Terminal)(简称终端(Terminal))来运行 SQL Shell。 从 GitHub repo https://github.com/intersystems/FirstLook-SQLBasics 获取本指南的实用程序文件和数据,包括 stock_table_demo_two.csv,其中包含一百万行股票表数据 Loader.xml,是一个包含实用程序方法的类文件,用于将 Stock_table_demo_two.csv 中的数据加载到InterSystems IRIS 表中。 运行 TuneTable 实用程序 如果您的 InterSystems IRIS 实例不再包含 StockTableDemoTwotable,请按照 Demo:Using Bitmap Indexing To Maximize Query Performance(《演示:使用位图索引最大化查询性能》)(在执行 SELECT DISTINCT 查询之前停止)的前四个步骤重新创建并加载它。 在 SQL Shell 中,在 FirstLook.StockTableDemoTwo 上运行 TuneTable 实用程序,如下所示: OBJ DO $SYSTEM.SQL.TuneTable("FirstLook.StockTableDemoTwo") 该命令在 SQL Shell 中不会生成可见的输出。 使用 EXPLAIN 关键字显示查询计划 这个演示假设您想获得所有"SELL"交易的平均价格。鉴于该表包含一百万条记录,所需的查询有可能非常慢。 虽然您可能已经想在 Price 和 TransactionType 字段上创建索引,但在开始优化工作之前,查看查询计划将具有指导意义。在 SQL Shell 中,您可以通过在查询前添加 EXPLAIN 关键字来显示查询计划。查询计划显示 SQL 查询优化器将如何使用索引(如果有索引的话),或者是否将直接读取表数据来执行语句。 要使用 EXPLAIN 关键字来显示查询计划,在 SQL Shell 中执行以下语句: EXPLAIN SELECT AVG(Price) As AveragePrice FROM FirstLook.StockTableDemoTwo WHERE TransactionType = 'SELL' 这将返回格式为 XML 的查询计划: xxxxxxxxxx Plan "<plans> <plan> <sql> SELECT AVG ( Price ) AS AveragePrice FROM FirstLook . StockTableDemoTwo WHERE TransactionType = ? /*#OPTIONS {""DynamicSQLTypeList"":""1""} */ </sql> <cost value=""1827000""/> Call module B. Output the row. <module name=""B"" top=""1""> Process query in parallel, partitioning master map FirstLook.StockTableDemoTwo.IDKEY into subranges of T1.ID values, piping results to temp-file A: SELECT count(T1.Price),sum(T1.Price) FROM %NOPARALLEL FirstLook.StockTableDemoTwo T1 where ((%SQLUPPER(T1.TransactionType) = %SQLUPPER(?))) Read temp-file A, looping on a counter. For each row: Accumulate the count([value]). Accumulate the sum([value]). </module> 演示:显示和解释优化前的查询计划 </plan> <plan> <sql> SELECT COUNT ( T1 . Price ) , SUM ( T1 . Price ) FROM %NOPARALLEL FirstLook . StockTableDemoTwo T1 WHERE ( ( %SQLUPPER ( T1 . TransactionType ) = %SQLUPPER ( ? ) ) ) %PARTITION BY T1 . ID > ? AND T1 . ID <= ? </sql> <cost value=""1827000""/> Call module B. Output the row. <module name=""B"" top=""1""> Read master map FirstLook.StockTableDemoTwo.IDKEY, looping on ID (with a range condition). For each row: Accumulate the count(Price). Accumulate the sum(Price). </module> </plan> </plans>" 您将看到为执行 SQL 查询而生成的查询计划可以分为多个模块,每个模块都执行计划的不同部分,例如评估子查询。 实际上,这个查询计划被分为两个独立的计划。顶部计划用于初始查询。它调用一个模块 B,在这个模块中,其中"主映射"被分区,并在每个分区上并行执行子查询。子查询的计划遵循初始查询的计划。 在 "Spotting Potential Performance Issues in Query Plan Results(在查询计划结果中发现潜在的性能问题)"中,您将学习如何识别这个查询的问题。 在管理门户(Management Portal)中使用 SQL 查询接口显示查询计划 InterSystems IRIS 在管理门户(Management Portal)中提供了一个基于 web 的接口,用于 SQL 查询执行和计划分析。要使用管理门户(Management Portal)中的 SQL 查询接口显示查询计划: 使用 InterSystems IRIS Basics:Connecting an IDE(《InterSystems IRIS 基础:连接一个 IDE》)中URL described for your instance(为您的实例描述的 URL),在浏览器中打开您的实例的管理门户(Management Portal)。 请确保您是在 USER 命名空间。 如果您还没有找到,可以: 在屏幕的顶部面板中,点击当前命名空间名称右侧的 SWITCH(交换)。 在弹出的窗口中,选择 USER(用户) 并点击 OK(确定)。 导航到 SQL 页面(System Explorer(系统资源管理器) > SQL)。 省略 EXPLAIN 关键字,将"Using the EXPLAIN Keyword to Show a Query Plan(使用 EXPLAIN 关键字显示查询计划)中的查询粘贴到 Execute Query(执行查询) 标签的文本字段中。 点击 Show Plan(显示计划) 来显示查询计划。 结果将如下所示: 解释这些结果是下一节的主题。 发现查询计划结果中潜在的性能问题 查看查询计划结果,您可以看到这个查询存在一些严重的潜在性能问题。如果您查看子查询的计划,也就是实际工作完成的地方,您可以看到第一个任务是 "读取主映射"。这意味着 InterSystems SQL 查询优化器不会使用任何索引来运行查询; 演示:测试查询优化 相反,查询将遍历表中的所有 ID。特别是在大表的情况下,这表明查询将不能很好地执行。 当您优化查询时,您会看到它的执行时间减少,查询计划也会有明显的变化。 注意: 相对成本可以很好地预测性能,但只是相对于某个特定的查询而言。如果您在表中添加了一个索引,并且看到相对成本下降了,那么很可能这个查询现在会运行得更快。然而,相对成本并不是为了比较两个不同查询的性能。 测试查询执行 要获取有关未优化查询将如何执行的一些实际数据,请在 SQL Shell 中运行它: SELECT AVG(Price) As AveragePrice FROM FirstLook.StockTableDemoTwo WHERE TransactionType = 'SELL' GO 输出将如下所示: xxxxxxxxxx AveragePrice 266.1595139195757844 1 Rows(s) Affected statement prepare time(s)/globals/cmds/disk: 0.0009s/6/1246/0ms execute time(s)/globals/cmds/disk: 0.2599s/1000075/8502571/0ms cached query class: %sqlcq.USER.cls5 语句准备和执行指标分别列出。特别注意以下两项: 执行时间为 0.2599 秒。虽然这个时间看起来并不算长,但可以通过使用索引大大改善。 在执行步骤中读取的 globals 数量为 1,000,075。(Globals 是 InterSystems IRIS 用来存储数据的多维稀疏数组(multidimensional sparse arrays);更多信息,请参见 Introduction to InterSystems IRIS Programming(《InterSystems IRIS 编程简介》)中的Introduction to Globals(Globals 简介)一章。为了提高查询性能,应该减少这个数字。您会在下一节看到这种情况。 重要提示: 准备工作只需一次:第一次重新规划查询。如果修改了相关表或添加或删除了索引,查询将自动重新规划。大多数应用程序只准备一次查询,但会多次执行。因此,在这个演示中,我们的重点将是调整执行性能。 演示:测试查询优化 向价格字段添加位片索引(Bitslice Index) 如果您的查询将包含一个或多个字段上的聚合函数,那么为这些字段中的一个或多个字段添加位片索引(bitslice index)可能会提高性能。 位片索引(bitslice index)将字段中的每个数字数据值表示为二进制位字符串,二进制值中的每个数字都有一个位图,以记录哪些行的二进制数字为 1。 因为我们想要获得所有"SELL"交易的平均价格,所以在 Price 字段中添加一个位片索引(bitslice index)是有意义的。要在 Price 字段上创建位片索引(bitslice index) PriceIdx,请在 SQL Shell 中执行以下语句: 演示:测试查询优化 CREATE BITSLICE INDEX PriceIdx ON TABLE FirstLook.StockTableDemoTwo (Price) CREATE BITSLICE INDEX PriceIdx ON TABLE FirstLook.StockTableDemoTwo (Price) xxxxxxxxxx 0 Rows Affected statement prepare time(s)/globals/cmds/disk: 0.0091s/2000/13151/0ms execute time(s)/globals/cmds/disk: 1.4268s/2087789/55765062/1ms cached query class: %sqlcq.USER.cls7 但是,正如您将在下面看到的,仅仅因为您创建了索引并不一定意味着 InterSystems SQL 查询优化器会使用它 。 测试位片索引(Bitslice Index)的效果 要查看新的位片索引(bitslice index)是否会对查询的执行方式或运行速度产生任何影响,请使用上述任何一种方法(SQL Shell 或管理门户(Management Portal))来显示查询计划。 正如您将看到的,查询计划仍然与以前相同。InterSystems SQL 查询优化器将不会使用新的索引。 运行查询产生的性能统计数据与您创建位片索引(bitslice index)之前几乎相同(0.2559 秒的执行时间与 0.2599 秒相比)。InterSystems IRIS 智能地缓存查询计划和数据,因此同一查询的后续运行可能会提高性能,鉴于查询性能时间略有不同,这里可能就是这种情况。 在机器上运行的其他应用程序也会影响性能。 SELECT AVG(Price) As AveragePrice FROM FirstLook.StockTableDemoTwo WHERE TransactionType = 'SELL' GO SELECT AVG(Price) As AveragePrice FROM FirstLook.StockTableDemoTwo WHERE TransactionType = 'SELL' xxxxxxxxxx AveragePrice 266.1595139195757844 1 Rows(s) Affected statement prepare time(s)/globals/cmds/disk: 0.0569s/35431/227191/0ms execute time(s)/globals/cmds/disk: 0.2559s/1000075/8502571/0ms cached query class: %sqlcq.USER.cls8 如果从查询中删除 WHERE 子句,当您显示查询计划时,将会看到完全不同的结果: 如您所见,读取位片索引(bitslice index)是查询计划的第一步。在这个计划中没有读取到"总映射"。 SQL 查询优化器也使用第二个索引 FirstLook.StockTableDemoTwo.$StockTableDemoTwo。这是位图范围索引, 在执行 CREATE TABLESQL 语句时自动创建。它是表中所有行的位图索引(bitmap index),而不仅仅是一个字段,每个位的值反映了该行是否实际存在。 演示:测试查询优化 然而,我们真正想要运行的查询包含一个 WHERE 子句。因此,我们必须找到一种方法,让 SQL 查询优化器在 WHERE 子句存在时使用索引。 向交易类型字段(TransactionType Field)添加位图索引(Bitmap Index) 如果您阅读了 InterSystems SQL Optimization Guide(《InterSystems SQL 优化指南》),您会发现 InterSystems SQL 查询优化器在与 WHERE 子句字段上的位图索引(bitmap index)结合使用时,通常会使用位片索引(bitslice index)。 这是因为没有 WHERE 子句的聚合查询可以简单地聚合索引中的所有数据。然而,为了只聚合满足 WHERE 条件的行,查询必须掩码那些不满足条件的行的位片索引(bitslice index)的位。在 WHERE 子句中的字段上有一个位图索引(bitmap index),允许有效地构建这个掩码。 幸运的是,查询中的另一个字段 TransactionType 是位图索引(bitmap index)的一个很好的候选者,因为它的可能值计数是两个("SELL"和"BUY")。 要向 TransactionType 字段添加位图索引(bitmap index),请在 SQL Shell 中执行以下语句: CREATE BITMAP INDEX TransactionTypeIdx ON TABLE FirstLook.StockTableDemoTwo (TransactionType) CREATE BITMAP INDEX TransactionTypeIdx ON TABLE FirstLook.StockTableDemoTwo (TransactionType) xxxxxxxxxx 0 Rows Affected statement prepare time(s)/globals/cmds/disk: 0.0069s/2001/13291/0ms execute time(s)/globals/cmds/disk: 1.1046s/2088960/19771584/0ms cached query class: %sqlcq.USER.cls7 重新测试查询性能 现在,您已经添加了位片索引(bitslice index)和位图索引(bitmap index):如果您显示的查询计划 SELECT AVG(Price) as AveragePrice FROM FirstLook.StockTableDemoTwo WHERE TransactionType = 'SELL' 在 SQL Shell 或管理门户(Management Portal)中,您会看到查询优化器使用您创建的两个索引来获得最佳性能。 还请注意,18742 的相对成本只是未优化查询的一小部分,其成本为 1827000。 演示:测试查询优化 最后,如果您在 SQL Shell 中运行这个查询,您会看到对 globals 的更有效使用(594 而不是 1000075)。 最关键的是,有索引的查询运行速度比无索引的查询快了近 85 倍(执行时间为 0.0031 秒,而非 0.2599)。 查看随时间变化的查询性能 SELECT AVG(Price) As AveragePrice FROM FirstLook.StockTableDemoTwo WHERE TransactionType = 'SELL' GO SELECT AVG(Price) As AveragePrice FROM FirstLook.StockTableDemoTwo WHERE TransactionType = 'SELL' xxxxxxxxxx AveragePrice 266.1595139195757844 1 Rows(s) Affected statement prepare time(s)/globals/cmds/disk: 0.0554s/34877/186130/0ms execute time(s)/globals/cmds/disk: 0.0031s/594/2878/0ms cached query class: %sqlcq.USER.cls8 为了随时间跟踪查询的性能,InterSystems IRIS 提供了查询统计数据,您将在下一节了解如何查看这些数据。 查看随时间变化的查询性能 要跟踪运行缓慢的查询或查看新查询在产品中的运行情况,您可以使用管理门户(Management Portal)中的 SQL Statements(SQL 语句)视图。要导航到这个视图,在管理门户(Management Portal)中打开 SQL 查询接口,并点击 SQL Statements(SQL语句)。 例如,如果您上面调整的查询在其原始(未优化的)计划下运行了 9 次,您可能会看到类似这样的结果: 点击 SQL Statement Text column(SQL 语句文本列)中的语句链接, 允许您以 SQL 形式查看查询: 您还可以使用缓存查询类的名称将 SQL 语句执行与 SQL Statements(SQL 语句)视图联系起来,该名称是 SQL Shell 中输出的最后一行,并列在 SQL Statements(SQL 语句) 的 Location(s)(位置)列中。 在您优化查询并运行几次后,您可以期望看到 Total time(总时间)和 Average time(平均时间)的改善列。 了解有关 InterSystems SQL 的更多信息 请注意,Count(计数)的值已经下降。这是因为位图和位片索引(bitslice index)的添加引起了查询计划的改变,这反过来又触发了对相关类的缓存查询的删除。该查询在新查询计划下总共运行了 8 次,平均每天 4 次。 了解有关 InterSystems SQL 的更多信息 要了解更多有关 SQL 和 InterSystems IRIS 的信息,请参见: 介绍材料 First Look:InterSystems SQL(《技术概要:InterSystems SQL》) Using InterSystems SQL(《使用 InterSystems SQL》) InterSystems SQL Reference(《InterSystems SQL 参考书目》) InterSystems SQL Overview(《InterSystems SQL 概述》) SQL 开发 SQL -- Things You Should Know(《SQL -- 您应该知道的事情》) Developing with InterSystems Objects and SQL(《使用 InterSystems Objects 和 SQL 开发》) 查询优化 InterSystems SQL Optimization Guide(《InterSystems SQL 优化指南》) Optimizing SQL Queries(《优化 SQL 查询》) 分片和可扩展性 First Look:Scaling for Data Volume with Sharding(《技术概要:带分片的数据卷扩展》) Scalability Guide(《可扩展性指南》) SQL 搜索 First Look:SQL Search with InterSystems IRIS(《技术概要:使用 InterSystems IRIS 进行 SQL 搜索》) Using InterSystems SQL Search(《使用 InterSystems SQL 搜索》) Creating iFind Indices for Searching Text Fields(《创建用于搜索文本字段的 iFind 索引》) JDBC First Look:JDBC and InterSystems IRIS (《技术概要:JDBC 和 InterSystems IRIS》) Using Java JDBC with InterSystems IRIS(《在 InterSystems IRIS 中使用 Java JDBC》)<文档> Java Overview (《Java 概述》) 了解有关 InterSystems SQL 的更多信息 Using JDBC with InterSystems IRIS(《在 InterSystems IRIS 中使用 JDBC》) <在线学习>
文章
Jingwei Wang · 九月 26, 2021

IRIS 2021 技术文档 First Look 11 用于.Net的InterSystems IRIS Native API

本文解释了如何使用 InterSystems IRIS Native 从 .NET 应用程序访问 InterSystems IRIS®数据平台 globals。IRIS Native 还允许您运行ObjectScript 方法、函数和Routine。在本文中,您首先将连接到 InterSystems IRIS。然后您将在 InterSystems IRIS 中设置和检索一个global 节点的值,并在另一个 global 节点上进行迭代。您还将调用 InterSystems IRIS 类方法。所有这些活动都将在 .NET 应用程序中执行。 为了让您体验 IRIS Native,而又不陷入细节困境,本次探索特意设计得很简洁。这些活动被设计成只使用默认设置和功能,这样您就可以熟悉功能的基本原理,而不必处理那些离题或过于复杂的细节。当您把 IRIS Native 引入您的生产系统时,您可能需要做一些不同的事情。请确保不要把这种对 IRIS Native 的探索与真实的情况相混淆! Globals 简介 InterSystems IRIS 提供了一种易于使用的方法来将数据存储在持久的多维数组中。global 是存储在 InterSystems IRIS 物理数据库中的多维数组。在应用程序中,globals 到物理数据库的映射基于当前命名空间,命名空间提供一个或多个物理数据库的逻辑统一视图。例如,要使用一个名为 ^Settings 的 global 将值 "Red "与键 "Color "关联起来,打开 InterSystems 终端并输入以下代码: set ^Settings("Color")="Red" 您可以利用 globals 的多维特性来定义一个更复杂的结构: set ^Settings("Auto1","Properties","Color") = "Red" set ^Settings("Auto1","Properties","Model") = "SUV" set ^Settings("Auto2","Owner") = "Mo" set ^Settings("Auto2","Properties","Color") = "Green" 探索 IRIS Native 现在,您已经准备好实验 IRIS Native 了。下面的简短演示将向您演示如何在 .NET 应用程序中使用 IRIS Native。(想试试 InterSystems IRIS .NET 开发和互操作性功能的在线视频演示?请看.NET 快速入门! 用前须知 要使用该程序,您需要一个安装了 .NET 框架和 Visual Studio 的 Windows 系统,以及一个运行中的 InterSystems IRIS 实例来连接。您对InterSystems IRIS 的选择包括多种类型的已授权的和免费的评估实例;实例不需要由您正在工作的系统托管(尽管它们必须相互具有网络访问权限)。关于如何部署每种类型的实例的信息(如果您还没有可使用的实例),请参见InterSystems IRIS 基础:连接一个 IDE中的部署InterSystems IRIS 。使用同一文档中的InterSystems IRIS 连接信息和 .Net IDE 中的信息将 Visual Studio 连接到您的 InterSystems IRIS 实例。 配置 Visual Studio 项目 首先,打开 Visual Studio 并创建一个新的控制台应用程序项目,选择 Visual C# 和 Console App (.NET Framework)(控制台应用程序(.NET 框架))选项。对于 Name(名称)字段,输入 netnative。 添加程序集引用 InterSystems.Data.IRISClient.dll 程序集必须存在于您的本地系统中;您可以从 https://github.com/intersystems/quickstarts-dotnet/tree/master/EFPlay/bin/Debug 下载它。如果 InterSystems IRIS 安装在您的本地系统或您可以访问的另一个系统上,则该程序集已经安装在子目录 install-dir\dotnet\bin\v4.5 中,其中 install-dir 是该实例的安装目录。 要将 InterSystems.Data.IRISClient.dll 的程序集引用添加到项目: 从 Visual Studio 主菜单中,选择 Project(项目) > Add Reference(添加引用)... 在出现的窗口中,点击 Browse(浏览).... 浏览到 InterSystems.Data.IRISClient.dll 文件的位置。 选择文件并点击 Add(添加)。 点击 OK(確定)。 在 Visual Studio Solution Explorer 中, InterSystems.Data.IRISClient.dll 程序集现在应该列在 Reference(引用)下。 使用 IRIS Native 现在,您已经准备好实验 IRIS Native 了。打开在创建 Visual Studio 项目时创建的文件(例如,Program.cs)。删除文件的默认内容并粘贴以下代码,用您的 InterSystems IRIS 实例的连接信息替换 conn.ConnectionString 中的值。(logfile 的值必须是本地系统上的可写路径)。您可以指定所示的 USER命名空间,也可以选择在实例上创建另一个命名空间。 using System; using InterSystems.Data.IRISClient; using InterSystems.Data.IRISClient.ADO; public class IRISNative { public static void Main(String[] args) { try { // open connection to InterSystems IRIS instance using connection string IRISConnection conn = new IRISConnection(); // edit this ConnectionString to match your environment conn.ConnectionString = "Server=localhost; Port=1972; Namespace=User; Password=SYS; User ID=_system; logfile=c:\\sandbox\\dbnative.log"; conn.Open(); // create IRIS Native object IRIS iris = IRIS.CreateIRIS(conn); Console.WriteLine("[1. Setting and getting a global]"); // setting and getting a global // ObjectScript equivalent: set ^testglobal("1") = 8888 iris.Set(8888, "^testglobal", "1"); // ObjectScript equivalent: set globalValue = $get(^testglobal("1")) Int16? globalValue = iris.GetInt16("^testglobal", "1"); Console.WriteLine("The value of ^testglobal(1) is " + globalValue); Console.WriteLine(); Console.WriteLine("[2. Iterating over a global]"); // modify global to iterate over // ObjectScript equivalent: set ^testglobal("1") = 8888 // ObjectScript equivalent: set ^testglobal("2") = 9999 iris.Set(8888, "^testglobal", "1"); iris.Set(9999, "^testglobal", "2"); // iterate over all nodes forwards Console.WriteLine("walk forwards"); IRISIterator subscriptIter = iris.GetIRISIterator("^testglobal"); foreach (var node in subscriptIter) { Console.WriteLine("subscript=" + subscriptIter.CurrentSubscript + ", value=" + node); } Console.WriteLine(); Console.WriteLine("[3. Calling a class method]"); // calling a class method // ObjectScript equivalent: set returnValue = ##class(%Library.Utility).Date(5) String returnValue = iris.ClassMethodString("%Library.Utility", "Date", 5); Console.WriteLine(returnValue); Console.WriteLine(); // close IRIS object and connection iris.Close(); conn.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); }}} 示例代码分为三个部分: 第一部分展示了如何设置一个 global 的值以及稍后如何检索它。这部分里面执行的命令等同于 ObjectScript 的 SET 和 GET 命令。 第二部分展示了如何迭代 global 的子节点,类似于ObjectScript中的 $ORDER函数。 第三部分展示了如何使用 IRIS Native 从您的 .NET 应用程序调用 ObjectScript 类方法。 如果您使用的是本地安装的实例,并且因此连接使用 localhost 作为服务器地址,那么程序可能使用本地共享内存连接,这比标准的 TCP/IP 连接还要快。 注意: ObjectScript 中的 Globals 以插入符号(^)开头。在使用 InterSystems IRIS Native API 的 .NET 应用程序中,这不是必需的。 运行练习 现在可以按 Ctrl+F5 运行演示应用程序了。如果示例执行成功,您应该会看到带有示例代码结果的打印输出: [1. Setting and getting a global] The value of ^testglobal(1) is 8888 [2. Iterating over a global] walk forwards subscript=1, value=8888 subscript=2, value=9999 [3. Calling a class method] Oct 30, 2018 在管理门户(Management Portal)中确认变更 接下来,使用以下程序在管理门户(Management Portal)中确认您的结果: 使用InterSystems IRIS 基础:连接一个 IDE中为您的实例描述的 URL,在浏览器中打开您的实例的管理门户(Management Portal)。 如果您不在代码指定的命名空间中,请切换到该命名空间。 导航到 Globals 页面(System Explorer(系统资源管理器) > Global)。您应该会看到在示例代码中创建的 testglobal。点击 VIEW 来查看其内容。 您应该会看到 global 的两个节点:^testglobal(1) = 8888 和 ^testglobal(2) = 9999。 了解有关 IRIS Native 的更多信息 有关 IRIS Native、globals 和 InterSystems IRIS 的更多信息,请参见: 用于.Net的 Native API 技术概要:用于Java的 InterSystems IRIS Native API 使用 Globals 用于.NET 的 InterSystems Managed Provider