mysql进阶 with-as 性能调优


使用前提:多次重复出现的子查询

with-as 意义:对于多次反复出现的子查询,可以降低扫描表的次数和减少代码重写,优化性能和使编码更加简洁


✿ 使用注意事项:

1、mysql版本: 8以及8以上的

2、首先定义子查询的临时虚拟表

语法: with 临时表名 as 子查询,定义出(子查询)的虚拟临时表,然后定义之后需要立马引用才有意义

即:定义好with子查询,但其后没有跟select查询引用,会报错!
即:临时虚拟表需要立即引用它,with子查询语句必须定义在引用它的select语句之前!

3、定义多个子查询的临时表,这多个子查询共用一个with子查询之间使用,隔开

注意:子查询与引用之间不能加,

 #WITH AS 语法: WITH 虚拟临时表名 AS (子查询) +引用

  WITH temp AS (select * from t_teacher) # 定义子查询
  (SELECT `name` FROM temp) t1,		    # 多次引用子查询的临时虚拟表
  (SELECT age FROM temp) t2,
  (SELECT sex FROM temp) t3
  WHERE t1.id = t2.id AND t1.id = t3.id and t2.id = t3.id;
  #WITH AS 语法(定义多个子查询)
  WITH 
	temp1 AS (select * from t_teacher), 
	temp2 AS (select * from t_stu),
	temp3 AS (select * from t_user)
	select count(*) FROM temp1......
	#....引用即可.....#

✿ 重复子查询之with-as是否使用效率对比:

  • 没有使用with-as:selet 物理表时扫描了两次
  • 使用了with-as:select 临时表,节约了一次加载时间
  • 14
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 26
    评论
摘 要 高校学生成绩管理工作是高等教育中的一个极为重要的环节,是院校学生管理的基础。面对种类繁多的数据和报表,手工处理方式已经很难跟上现代化管理的步伐,传统的文件管理方式进行成绩管理,效率很低,耗时费力,容易出错,安全性也存在问题。特别是在查询上,由于文件过多,带来很多不便。随着计算机及通讯技术的飞速发展,高等教育对教务管理工作提出了更高的要求。尽快改变传统的管理模式,运用现代化手段进行科学管理。 本设计研究的是基于J2EE的高校成绩管理系统的设计与实现。本系统是基于J2EE开发的成绩管理系统,弥补了人工管理的不足,提高了一定的效率。主要功能包括教师对学生成绩的记录,生成总评成绩,成绩单的提交。学生查询相关的成绩信息。管理员对学生、教师,课程、班级进行综合管理。该系统为教务处人员提供了强大的成绩管理功能,为教师提供了对平时成绩和期末成绩方便的管理,为学生提供了一个方便快捷的查询功能。本设计的开发工具使用MyEclipse,数据库使用的MySQL,框架是struts整合hibernate。 关键词:J2EE; 成绩管理; MySQL; MyEclipse Abstract College student grade management is a very important aspect of higher education,is the foundation of college students management. Faced with a wide variety of data and statements, the manual processing methods have been difficult to keep up with the pace of modern management, the traditional document management about grade management, is inefficient, time-consuming effort, error-prone, and also existing security issues. Because too many documents, it brings a lot of inconvenience in the query. With the computer and the rapid development of communication technology, higher education must meet a higher demand. We should change the traditional mode of management and use modern means of scientific management as soon as possible. The design based on J2EE technology mainly research about Implementation of grade management system of universities. The system is based on J2EE platform, cover the deficiencies of manual management, and improve the efficiency of management. Main features including: teachers record the grade of students in the term examines, generate the report card to examine. Students can query their information at any time with this system. Administrator can manage the students, teachers, curriculum, classes together. The system for the Registry staff with a powerful performance management capabilities, provide teachers with the usual results and final results for the management, provide students with a convenient and efficient enquiry function. The development tools is MyEclipse, database is MySQL, integrated framework is struts and hibernate. Key words: J2EE; Grade Management; MySql; MyEclipse 目 录 Abstract II 1 绪论 1 1.1高校学生成绩管理系统实施的背景分析 1 1.2选题的目的及意义 1 2 J2EE平台及其支撑技术 3 2.1 J2EE平台 3 2.1.1 J2EE简介 3 2.1.2 JSP技术 5 2.1.3 Servlet技术 7 2.1.4 EJB技术 8 2.1.5 J2EE发展趋势 9 2.2 MVC模式介绍 10 2.3 Struts框架介绍 14 2.4 Hibernate框架介绍 16 3 基于J2EE技术平台的学生成绩管理分析 18 3.1系统可行性分析. 18 3.1.1技术可行性 18 3.1.2经济可行性 18 3.1.3运行可行性 18 3.2系统需求分析 18 3.3系统整体说明 19 3.4系统模块的功能概述 19 4 系统总体设计 20 4.1.系统结构图 20 4.1.1包组织结构图 20 4.3数据流程图设计 21 4.4.1 E-R图 22 4.3主要功能模块的设计 22 4.2.1用户登录模块设计 22 4.2.2管理员管理模块设计 23 4.2.3教师成绩录入和修改模块设计 23 4.2.4学生管理模块设计 23 5 基于J2EE技术平台的系统详细设计 24 5.1数据库详细设计 24 5.1.1 数据库需求分析 24 5.1.2 数据库概念结构设计 25 5.1.3 数据库逻辑结构设计 26 5.1.4 数据库结构的实现 28 5.1.5数据库模型 30 6 系统编码与测试 31 6.1系统编码说明 31 6.1.1系统配置文件 31 6.1.2系统运行效果图示. 35 6.1.3系统主要功能模块详细实现 40 6.1.3.1管理员管理模块详细介绍 40 6.1.3.2管理员管理模块代码说明 40 6.2 系统开发环境的搭建 47 6.2.1软件环境的配置 47 6.2.2硬件环境的配置 47 6.3系统性能测试 47 6.3.1安全性测试 47 6.3.2稳定性测试 47 7 总结与展望 48 7.1总结 48 7.2展望 48 参考文献: 49 致谢 49

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 26
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

伟庭大师兄

你的鼓励是我最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值