Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsdir 性能优化 #159

Open
hjyssg opened this issue Jan 8, 2021 · 5 comments
Open

lsdir 性能优化 #159

hjyssg opened this issue Jan 8, 2021 · 5 comments
Labels

Comments

@hjyssg
Copy link
Owner

hjyssg commented Jan 8, 2021

 const time1 = getCurrentTime();

 .........sql

time2 = getCurrentTime();
 timeUsed = (time2 - time1) / 1000;
 console.log("[/api/LsDir] ", timeUsed, "s")

.......loop

time2 = getCurrentTime();
timeUsed = (time2 - time1) / 1000;
console.log("[/api/LsDir] ", timeUsed, "s")

原来慢的不是sql,而是loop操作。
loop操作用了0.2s

@hjyssg
Copy link
Owner Author

hjyssg commented Jan 9, 2021

一般,WHERE在前,GROUP BY在后,即先进行筛选,然后进行分组;

HAVING只能跟在GROUP BY之后,对分组后的聚合结果进行筛选;HAVING的前提是分组;WHERE在最前,最先对原始数据进行一遍筛选;

作者:小甜瓜Melon
链接:https://www.jianshu.com/p/42cf6f5b30c1
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

@hjyssg
Copy link
Owner Author

hjyssg commented Jan 9, 2021

当一个查询语句同时出现了where,group by,having,order by的时候,执行顺序和编写顺序是:
1.执行where xx对全表数据做筛选,返回第1个结果集。

2.针对第1个结果集使用group by分组,返回第2个结果集。

3.针对第2个结果集中的每1组数据执行select xx,有几组就执行几次,返回第3个结果集。
4.针对第3个结集执行having xx进行筛选,返回第4个结果集。

5.针对第4个结果集排序。

@hjyssg hjyssg added the note label Jan 9, 2021
@hjyssg
Copy link
Owner Author

hjyssg commented Jan 9, 2021

文件夹名有 _ % 会被sql当成wildcard

@hjyssg
Copy link
Owner Author

hjyssg commented Jan 9, 2021

@hjyssg
Copy link
Owner Author

hjyssg commented Jan 15, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant