大前端

osc_35890167 2021-04-07 22:01:08
java c++


XZ:大前端

比前端全栈更上一层
专为实际开发经验1年以上的前端工程师设计
高效全能架构前端
函數操作
對條件字段做函數操作走不了索引。

select * from t1 where date =‘2019-05-21’;
優化:改成範圍查询

select * from t1 where c>=‘2019-05-21 00:00:00’ and c<=‘2019-05-21 23:59:59’;
隱式轉換
操作符與不同類型的操作對象一同運用時,就會發作類型轉換以使操作兼容。

select user_name,tele_phone from user_info where tele_phone =11111111111; / tele_phone varchar /
實践會做函數操作:

select user_name,tele_phone from user_info where cast(tele_phone as singed int) =11111111111;
優化:類型統一

select user_name,tele_phone from user_info where tele_phone =‘11111111111’;
含糊查询
通配符在前面

select * from t1 where a like ‘%1111%’;
優化:含糊查询必需包含條件字段前面的值

select * from t1 where a like ‘1111%’;
範圍查询
範圍查询數據量太多,需求回表,因而不走索引。

select * from t1 where b>=1 and b <=2000;
優化:降低單次查询範圍,分屢次查询。(實践可能速度沒得快太多,倡議走索引)

select from t1 where b>=1 and b <=1000;
show profiles;
±---------±-----------±-----------------------------------------+
| Query_ID | Duration | Query |
±---------±-----------±-----------------------------------------+
| 1 | 0.00534775 | select 
from t1 where b>=1 and b <=1000 |
| 2 | 0.00605625 | select * from t1 where b>=1 and b <=2000 |
±---------±-----------±-----------------------------------------+
2 rows in set, 1 warning (0.00 sec)
計算操作
即便是简單的計算

explain select * from t1 where b-1 =1000;
優化:將計算操作放在等號後面

explain select * from t1 where b =1000 + 1;

翻了很多题解,只能看懂这种解法,够直观够暴力。

class Solution {
public:
vector<string> restoreIpAddresses(string s) {
vector<string> res;

 for (int a = 1; a < 4; a ++ )
for (int b = 1; b < 4; b ++ )
for (int c = 1; c < 4; c ++ )
for (int d = 1; d < 4; d ++ ) //abcd分别表示四段ip地址长度
{
if (a + b + c + d == s.size()) //四段长度刚好
{
string s1 = s.substr(0, a); //分别截取四段ip地址
string s2 = s.substr(a, b);
string s3 = s.substr(a + b, c);
string s4 = s.substr(a + b + c);
if (check(s1) && check(s2) && check(s3) && check(s4))
{
string ip = s1 + '.' + s2 + '.' + s3 + '.' + s4;
res.push_back(ip);
}
}
}
return res;
}
bool check(string s) //判断ip地址每段的第一位不为0,或只有一位且该位为0
{
if (stoi(s) <= 255)
if (s[0] != '0' || (s[0] == '0' && s.size() == 1)) return true;
return false;
}

};
下一篇:【切割问题都可以用回溯搜索来解决】详解!
著作权归作者所有
1
条评论

最热

编辑
预览

评论

阿兹卡班在逃犯
L2
2021-03-13
贴一个java的

class Solution {
public List<String> restoreIpAddresses(String s) {
List<String> list = new ArrayList();
for(int a=1; a<4; a++){
for(int b=1; b<4; b++){
for(int c=1; c<4; c++){
for(int d=1; d<4; d++){
if(a+b+c+d==s.length()){
String s1 = s.substring(0, a);
String s2 = s.substring(a, a+b);
String s3 = s.substring(a+b, a+b+c);
String s4 = s.substring(a+b+c, a+b+c+d);

 if(check(s1)&&check(s2)&&check(s3)&&check(s4)){
String ip = s1+"."+s2+"."+s3+"."+s4;
list.add(ip);
}
}
}
}
}
}
return list;
}
版权声明
本文为[osc_35890167]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/5067864/blog/5011507

  1. Element tree control: invalid to modify current node key
  2. linux下安装apache(httpd-2.4.3版本)各种坑
  3. How to install Apache (httpd-2.4.3) under Linux
  4. 程序员业余时间写的代码也算公司的?Nginx之父被捕引发争议
  5. Nacos serialize for class [com.alibaba.nacos.common.http.HttpRestResult] failed.
  6. Do programmers write code in their spare time? Controversy over the arrest of nginx's father
  7. Nacos serialize for class [ com.alibaba.nacos . common.http.HttpRestResult ] failed.
  8. Seamless management of API documents using eolink and gitlab
  9. vue 的基础应用(上)
  10. 28岁开始零基础学前端,这些血的教训你一定要避免
  11. Basic application of Vue
  12. Starting at the age of 28, you must avoid these bloody lessons
  13. Ubuntu 16.04 can not connect to the wireless solution and QQ installation
  14. Industry security experts talk about the rapid development of digital economy, how to guarantee the security of data elements?
  15. 利用Vue实现一个简单的购物车功能
  16. Behind the "tireless classroom" and teacher training, can byte education really "work wonders"?
  17. Using Vue to realize a simple shopping cart function
  18. 【css】伪类和伪类元素的区别
  19. 【css效果】实现简单的下拉菜单
  20. 【vue】父子组件传值
  21. The difference between pseudo class and pseudo class elements
  22. [CSS effect] simple drop-down menu
  23. [Vue] value transfer by parent-child component
  24. 【css】设置table表格边框样式
  25. 【css】修改input,textarea中的placeholder样式
  26. vue-router的两种模式(hash和history)及区别
  27. CSS3的滤镜filter属性
  28. [CSS] set table border style
  29. [CSS] modify the placeholder style in input and textarea
  30. Two modes of Vue router (hash and History) and their differences
  31. Filter property of CSS3
  32. 全局安装gulp 报错问题解决
  33. Solution of error report in global installation of gulp
  34. 18个好用的自定义react hook
  35. 你应该知道的常用服务器HTTP状态码?
  36. 18 user defined react hooks
  37. What HTTP status codes should you know about common servers?
  38. 手把手教你打造属于自己团队的前端小报系统
  39. Hand in hand to teach you to build your own front-end tabloid system
  40. In 2021, enterprise SEO actual operation, how to less update, batch ranking regional words?
  41. vue cli4.0 快速搭建项目详解
  42. Vue cli4.0 quick build project
  43. vue-cli脚手架安装
  44. Installation of Vue cli scaffold
  45. [JS knowledge] method of getting elements from DOM
  46. 【jQuery效果】文字滚动
  47. [jQuery effect] text scrolling
  48. [front end] live broadcast of user experience optimization series, real-life sharing of front-line celebrities
  49. React native introduces third party Android SDK
  50. Using html2canvas to generate shared images, CDN images do not show the problem
  51. Using hooks to write react components
  52. Explain the module hot replacement function of webpack in detail
  53. An incomplete guide to writing a simple native wechat applet
  54. How JavaScript calculates 1 + 1 - Part 1 creates a source string
  55. Jsonp method to solve cross domain problems
  56. Canvas animation demo (from zero to one)
  57. El dialog of elementui component encapsulation
  58. Transition group of Vue source code
  59. When encountering bracket validity, next larger element, specific minimum value, try stack
  60. Vue3 virtual DOM