数据库的优化
在实际工作中,通常会遇到某个进程或者请求运行的十分缓慢,其中大部分的时间都花在了数据库的查询和写入上,每次遇到这个问题就十分头痛。首先,鉴于我们是很底层的程序员,没法花钱给企业加硬件,那我们能完成的事情就是用头脑取分析并优化每一条查询,来获得查询效率的提升。
老高总结了一下工作中遇到的问题,以后再遇到相同的问题后可以快速排查。
在实际工作中,通常会遇到某个进程或者请求运行的十分缓慢,其中大部分的时间都花在了数据库的查询和写入上,每次遇到这个问题就十分头痛。首先,鉴于我们是很底层的程序员,没法花钱给企业加硬件,那我们能完成的事情就是用头脑取分析并优化每一条查询,来获得查询效率的提升。
老高总结了一下工作中遇到的问题,以后再遇到相同的问题后可以快速排查。
总结一下目前持有的币种吧(排名不分先后,量也都不大)
唉,错过了成为百万负翁的机会,买这个就当买个彩票吧 ?
顺便分享一波糖果:
IP6用到现在,系统版本已经是11了,眼看着系统越来越卡,到现在逛个淘宝都不想用IP看了。废话不多说,这篇文章就是想记录一下查询能够降级的最低版本,让IP6再能撑几年吧。
下面两个地址可以查询能降级的版本,二者好像数据不太一致,待我降级完成后更新。
在mac上ssh自己的服务器后总是会断开,比如wget某一个东西,或者tar一个大文件,如果你总是受此困扰,不妨尝试一下此文里的配置。
搬瓦工新入的KVM架构的机器,默认内核版本是4.10.4
,如果是本地用ISO安装的系统,默认内核版本可能更低,比如3.10.0
,如果我们想要获取到最新的Linux特性,那么就必须升级内核版本到最新,我们可以用很简单的几个命令就可做到。
方括号的[]在json中调试是一个数组,而花括号{}在json中表示一个对象,不过二者在PHP中基本上一个empty就可以判断为i空了,但在js里好像就有一些麻烦了,可能需要下面的判断方式。
p = []
if((Array.isArray(p) && p.length === 0)){
alert('[]');
}
p = {}
if(Object.prototype.isPrototypeOf(p) && Object.keys(p).length === 0){
alert('{}');
}
WAY1:
$a = json_decode('{}');
echo json_encode($a);
WAY2:
$a = new stdclass;
// $a = new ArrayObject();
echo json_encode($a);
虽然花括号{}和方括号的[]二者在PHP和JSON中都表示不同的东西,但是突然要返回空对象还是冷不丁的想一下,我上哪儿去找一个空对象啊? ?
<script>
NProgress.start();
(function(funcName, baseObj) {
// The public function name defaults to window.docReady
// but you can pass in your own object and own function name and those will be used
// if you want to put them in a different namespace
funcName = funcName || "docReady";
baseObj = baseObj || window;
var readyList = [];
var readyFired = false;
var readyEventHandlersInstalled = false;
// call this when the document is ready
// this function protects itself against being called more than once
function ready() {
if (!readyFired) {
// this must be set to true before we start calling callbacks
readyFired = true;
for (var i = 0; i < readyList.length; i++) {
// if a callback here happens to add new ready handlers,
// the docReady() function will see that it already fired
// and will schedule the callback to run right after
// this event loop finishes so all handlers will still execute
// in order and no new ones will be added to the readyList
// while we are processing the list
readyList[i].fn.call(window, readyList[i].ctx);
}
// allow any closures held by these functions to free
readyList = [];
}
}
function readyStateChange() {
if ( document.readyState === "complete" ) {
ready();
}
}
// This is the one public interface
// docReady(fn, context);
// the context argument is optional - if present, it will be passed
// as an argument to the callback
baseObj[funcName] = function(callback, context) {
if (typeof callback !== "function") {
throw new TypeError("callback for docReady(fn) must be a function");
}
// if ready has already fired, then just schedule the callback
// to fire asynchronously, but right away
if (readyFired) {
setTimeout(function() {callback(context);}, 1);
return;
} else {
// add the function and context to the list
readyList.push({fn: callback, ctx: context});
}
// if document already ready to go, schedule the ready function to run
if (document.readyState === "complete") {
setTimeout(ready, 1);
} else if (!readyEventHandlersInstalled) {
// otherwise if we don't have event handlers installed, install them
if (document.addEventListener) {
// first choice is DOMContentLoaded event
document.addEventListener("DOMContentLoaded", ready, false);
// backup is window load event
window.addEventListener("load", ready, false);
} else {
// must be IE
document.attachEvent("onreadystatechange", readyStateChange);
window.attachEvent("onload", ready);
}
readyEventHandlersInstalled = true;
}
}
})("docReady", window);
docReady(function() {
NProgress.done();
});
</script>
https://github.com/jfriend00/docReady/blob/master/docready.js