当前位置:网站首页>73- find the SQL example during the business peak period (report development class)
73- find the SQL example during the business peak period (report development class)
2022-06-22 21:21:00 【Tiger Liu】
The following business logic code segment was proposed in the technical discussion group :
The business logic of this code is to find 2019 With the largest annual business volume 61 second ( I think the original intention should be 60 second , The code is not rigorous enough ) Interval and business volume .
This business question mainly uses plsql complete , It is a typical programmer's thinking , The execution efficiency is obviously very low , My advice is to press to_char(date_created,'yyyymmdd hh24mi') do group by, Then find the maximum ,sql The writing method is relatively simple , I believe that most developers should be able to simply write .
But the subject added other requirements , It may be necessary to make statistics at different time intervals , such as 15 Second interval ,30 Second interval, etc .
In response to this demand , I give SQL It is written as follows ( With 15 Second interval as an example ):
The title owner made a performance comparison between the two writing methods ,1000 More than a million records , The writing method I provided is time-consuming 125 second , primary plsql It takes time to write 1371 second ( This speed is unacceptable ), Efficiency difference 10 Several times , If the amount of data is large , The difference in efficiency will be even greater , And the optimized sql You can also use parallelism , It can speed up .
The query above , The starting point of the interval is fixed , This kind of writing is not too complicated . If we extend this problem further , For example, check which is continuous in a year 10 The business volume is the highest in days ,sql It is relatively complicated , Here's how I put it :
Here are some uses Analysis function Two small cases of , You can refer to it . meanwhile , Use with Of CTE Writing will make sql The level of is relatively clear , Improve the readability of the code .
If you have a better way of writing , You might as well write it in your message , Let's learn together .
边栏推荐
猜你喜欢

一行代码为特定状态绑定SwiftUI视图动画
![[redis]redis的持久化操作](/img/83/9af9272bd485028062067ee2d7a158.png)
[redis]redis的持久化操作

The access succeeds but an exception is thrown: could not find acceptable representation
![[206. reverse linked list]](/img/c8/d83655395379a512c8b67a82dc4cae.png)
[206. reverse linked list]

One line of code binds swiftui view animation for a specific state

las 点云创建网格

Easyclick fixed status log window

R 语言 UniversalBank.csv“ 数据分析

2022危险化学品经营单位主要负责人上岗证题库及模拟考试

建立自己的网站(12)
随机推荐
Baijia forum Daqin rise (lower part)
2022危险化学品经营单位主要负责人上岗证题库及模拟考试
EasyClick 固定状态日志窗口
基于C语言开发工资管理系统 课程论文+源码及可执行exe文件
[redis] three new data types
Visualization of wine datasets in R language
Learning websites that programmers must see
Objective-C不同数据类型占用字节大小
Arcgis中las点云数据抽稀
Pytorch's model saving, loading and continuing training
Performance test (I)
[redis]Redis6的事务操作
基于AI驱动大分子药物发现,「华深智药」获近5亿元A轮融资
PHP image making
R 语言 wine 数据集可视化
[palindrome structure of or36 linked list]
las 点云创建网格
程序员必看的学习网站
Fluent system architecture
使用Charles抓包