数据库连接池
数据库连接池为什么需要连接池当一个数据库操作任务到来时,程序需要和数据库建立连接,进行三次握手、数据库用户验证,然后执行SQL语句,最后用户退出、四次挥手关闭连接。每次任务都执行这样的流程,那么整个流程中,真正有效而且变化的只有执行SQL语句这一步骤,而且每次建立连接、用户验证、关闭连接都耗费时间。 因此,考虑能不能将连接只创建一次,然后复用长连接执行 SQL 语句呢?这需要池化技术。 池化技术可以减少资源对象的创建次数,提高程序的响应性能,特别是对高并发场景下的性能提升非常明显。适合使用池化技术缓存的资源对象具有如下特点: 对象创建时间长 对象占用资源多 对象创建后可以重复使用 数据库连接池数据库连接池是程序启动时建立一定数量的数据库连接,并将这些连接组成一个连接池,当程序需要用到连接去进行数据库操作的时候,直接从连接池中获取一个连接对象使用,使用完毕后,将连接对象归还给连接池。 优点:(1)资源复用。避免了频繁的创建、释放连接引起的性能开销,减少系统消耗,增进系统运行环境的稳定(减少内存碎片和数据库临时线程/进程数量)。(2)更快的系统响应速度。数据库连接池初始化完成后,直接利 ...
美赛C题学习
美赛C题学习如果自建模型,可以参考2218931的4.2.1,2218931的论文描述值得学习,最后的信也比较有特色 跟现实相结合也是很重要的点,最好能有案例支撑,虽然说在C题中不常见,但其实有的地方也可以加上 时间序列预测可以关注一些特殊的时间节点,比如节假日,季节性,节假日和季节性都有可能影响时间序列的预测。 ARIMA:经典时间序列预测模型,使用自回归积分移动平均模型,该模型可以对时间序列数据进行预测,并且可以对时间序列数据进行平滑处理,可以参考下2203120的写法。 GRU:时间序列预测,和LSTM类似,但是GRU的更新门和遗忘门合并为更新门,输入门和输出门合并为输出门,所以GRU的参数更少,更便于计算. SIR:SIR模型,用于传染病传播的预测,S表示易感者,I表示感染者,R表示康复者,也适用于某些突然爆火的事件。 Prophet:时间序列预测,使用Facebook的Prophet算法,该算法基于时间序列历史数据,拟合出一个趋势和季节性,然后预测未来的时间序列。参考2301192,2200688 卡尔曼滤波算法 LightGBM:LightGBM是一种基于梯度提 ...
npm install 报错 npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher.
npm install 报错:npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/ 首先进入所给的网址查看: 查看自己的Node.js和npm版本: 发现版本够高(Node.js最好在18及以上, npm在7及以上) 执行所给代码:1npm install -g https://tls-test.npmjs.com/tls-test-1.0.0.tgz 重新执行npm install,发现依旧报错 查看设置的npm源: ...
西电数据库openGauss平台练习
西电数据库openGauss平台练习仅记录平台标注中等难度及以上的题目 试卷编号:41试卷名称:gongsi 条件:公司数据库有如下关系模式: 员工employee(员工号eno,员工姓名ename,员工年龄eage,所在部门号dno,工资salary,工作日期work); 部门depart(部门号dno,部门名称dname,部门经理员工号dman)。 题目3:查询每个部门的部门号、员工平均工资。12select dno, AVG(salary)from employee group by dno 题目4:查询员工的中位数工资。1234select distinct salary from employee a where (select count(*) from employee b where b.salary>=a.salary) -(select count(*) from employee b where b.salary<=a.salary)between -1 and 1 这道题比较容易踩坑的地方是题目没有说明它对中位数的定义,这里是将多个中位数返回回去,而 ...
MySQL索引一
MySQL索引一什么是索引索引是一种用于快速查询和检索数据的数据结构,其本质可以看成是一种排序好的数据结构。 索引的作用就相当于书的目录。打个比方: 我们在查字典的时候,如果没有目录,那我们就只能一页一页的去找我们需要查的那个字,速度很慢。如果有目录了,我们只需要先去目录里查找字的位置,然后直接翻到那一页就行了。 在 MySQL 中,无论是 Innodb 还是 MyIsam,都使用了 B+树作为索引结构。 索引的优缺点优点: 提高数据检索效率,降低数据库IO成本 降低数据排序成本,降低CPU消耗 通过创建唯一性索引,可以保证数据库表中每一行数据的唯一性。 缺点: 索引需要占物理空间 索引需要定期维护,增删改数据时需要维护索引,降低数据写入效率 索引底层数据结构选型哈希表哈希表是一种以键-值(key-value)存储数据的结构,只要输入待查找值即 key,就可以找到其对应的值即 value。因此哈希表可以快速检索数据(接近 O(1))。 为何能够通过 key 快速取出 value 呢? 原因在于 哈希算法(也叫散列算法)。通过哈希算法,我们可以快速找到 key 对应的 index ...
MySQL规范
MySQL规范数据库命名规范 所有数据库对象名称必须使用小写字母并用下划线分割 所有数据库对象名称禁止使用 MySQL 保留关键字(如果表名中包含关键字查询时,需要将其用单引号括起来) 数据库对象的命名要能做到见名识意,并且最好不要超过 32 个字符 临时库表必须以 tmp 为前缀并以日期为后缀,备份表必须以 bak 为前缀并以日期 (时间戳) 为后缀 所有存储相同数据的列名和列类型必须一致(一般作为关联列,如果查询时关联列类型不一致会自动进行数据类型隐式转换,会造成列上的索引失效,导致查询效率降低) 数据库基本设计规范所有表必须使用 InnoDB 存储引擎没有特殊要求(即 InnoDB 无法满足的功能如:列存储,存储空间数据等)的情况下,所有表必须使用 InnoDB 存储引擎 数据库和表的字符集统一使用 UTF8兼容性更好,统一字符集可以避免由于字符集转换产生的乱码,不同的字符集进行比较前需要进行转换会造成索引失效,如果数据库中有存储 emoji 表情的需要,字符集需要采用 utf8mb4 字符集。 所有表和字段都需要添加注释使用 comment 从句添加表和列的备注,从一开始就进 ...