当前位置:网站首页>Compare the performance of query based on the number of paging data that meet the query conditions
Compare the performance of query based on the number of paging data that meet the query conditions
2022-04-23 17:20:00 【I know why you're here】
Form writing habits together ! This is my participation 「 Nuggets day new plan · 4 Yuegengwen challenge 」 Of the 21 God , Click to see the event details .
Antecedents feed
-
As a front end , We don't just have to be able to write pages , Interface , Sometimes we need to use node To write some interfaces for the project . As the most common list interface , I believe we are all familiar , After all, this is the most commonly used .
-
Ordinary list interfaces generally have conditional search , Pagination, etc . And as paging , As image java Such a big brother , The ecology is complete , General framework will help you do paging query , You don't need to do more by yourself .
-
And as a newborn Nodejs, Although some frameworks are available , But I still prefer to write by myself sql sentence , And this is the time to encounter a problem : It is during list query , Usually, we need to return the number of qualified data to the front end .
-
After unremitting efforts, we found two solutions
- One is to query paging data , Execute another statement to query all the conditions , Then get the total . It needs to be performed twice sql sentence .
- One is through SQL_CALC_FOUND_ROWS Complex queries , Get paging data and total number at the same time . There are two statements , But there is only one implementation .
Comparison of solutions
I am here Navicat Premium Two statements are used on the tool to 1k、10k、100k、1000k、10000k The amount of data tested .
-
The first statement template is :select * from xxx limit 1,1000;select COUNT(*) from xxx;
-
The second statement template is :select SQL_CALC_FOUND_ROWS * from xxx;select FOUND_ROWS() total;
-
notes : The above example is just an ordinary query statement , If you use a connected table , Multi table query, etc , You can change it yourself .
-
Simply use tools to query , Of the query sql Statement is a join table query : give the result as follows
- 1k data :
-
The result of the first scheme :
-
The result of the second scheme :
-
- 10k data :
-
First option :
-
Second option :
-
- 100k data
- First option :
- Second option :
- First option :
- 1000k data
- The first solution :
- The second solution :
- The first solution :
- 10000k data
- The first solution
- The second solution :
- The first solution
- 1k data :
-
summary : According to the above results, we can see , Without considering the specific connection mode of the actual back-end to the database , Complex query, that is, the first query method, takes several times as long as non complex query .
summary
- Model :MacBook pro m1pro chip ,10 Core CPU ,16G Memory .
- The above experiments are used when generating data npm-mysql Package to connect to the database , And insert data . The connection method is connection pool .
- Then it will combine mysql package , and mysql2 Package and real node Compare the two ways of connecting data query .
- The above experimental data are not enough to generalize , But it also has reference value . If other students have any suggestions, please speak enthusiastically .
- I hope the comment area is a peaceful technical exchange , Comments with strong personal negative emotions will be deleted .
版权声明
本文为[I know why you're here]所创,转载请带上原文链接,感谢
https:https://yzsam.com/html/pBbJso.html
边栏推荐
- [registration] tf54: engineer growth map and excellent R & D organization building
- Using quartz under. Net core -- preliminary understanding of [2] operations and triggers
- Use between nodejs modules
- Metaprogramming, proxy and reflection
- Shell-awk命令的使用
- Shell-入门、变量、以及基本的语法
- 1-2 characteristics of nodejs
- Detailed explanation of C webpai route
- [batch change MySQL table and corresponding codes of fields in the table]
- [difference between Oracle and MySQL]
猜你喜欢

Get the column name list of the table quickly in Oracle

JS, entries(), keys(), values(), some(), object Assign() traversal array usage

On lambda powertools typescript

基于51单片机红外无线通讯仿真

Detailed explanation of Milvus 2.0 quality assurance system
![[WPF binding 3] listview basic binding and data template binding](/img/2e/fbdb4175297bb4964a8ccfd0b909ae.png)
[WPF binding 3] listview basic binding and data template binding

.Net Core3. 1 use razorengine NETCORE production entity generator (MVC web version)

自定义my_strcpy与库strcpy【模拟实现字符串相关函数】
![[PROJECT] small hat takeout (8)](/img/54/0187eeb637f4dcd4ad3969b00e2b77.png)
[PROJECT] small hat takeout (8)

Document operation II (5000 word summary)
随机推荐
Use of todesk remote control software
freeCodeCamp----prob_ Calculator exercise
1-2 JSX syntax rules
Website_ Collection
How does matlab draw the curve of known formula and how does excel draw the function curve image?
Paging SQL
JS, entries(), keys(), values(), some(), object Assign() traversal array usage
Promise (III)
Your brain expands and shrinks over time — these charts show how
ClickHouse-SQL 操作
.Net Core3. 1 use razorengine NETCORE production entity generator (MVC web version)
If you start from zero according to the frame
Shell - introduction, variables, and basic syntax
Go language, array, string, slice
Understanding and small examples of unity3d object pool
Document operation II (5000 word summary)
Customize my_ Strcpy and library strcpy [analog implementation of string related functions]
[markdown notes]
2.Electron之HelloWorld
Indexes and views in MySQL