WARNING: This article may be obsolete
This post was published in 2021-10-17. Obviously, expired content is less useful to users if it has already pasted its expiration date.
This post was published in 2021-10-17. Obviously, expired content is less useful to users if it has already pasted its expiration date.
This article is categorized as "Garbage" . It should NEVER be appeared in your search engine's results.
Table of Contents
删除wp_posts-revisions能提高性能吗
长期以来我一直没有删过 wp_posts 里的 revisions 条目,今天我尝试了一下,把所有 revisions 全部删掉:
删除以后,表 wp_posts 占用空间降了85%,但 页面平均生成时间 并没有任何改善。原因是:即使在删掉 revisions 之前,我的 wp_posts 占用空间都还没有MariaDB设置的 innodb-buffer-pool-size 大。
所以我又把 revisions 给加回去了。
Merge sort
快速理解
图解:🔗 [图解排序算法(四)之归并排序 - dreamcatcher-cx - 博客园] https://www.cnblogs.com/chengxiao/p/6194356.html
python merge sort
附带了python代码的解释:🔗 [python归并排序--递归实现 - 简书] https://www.jianshu.com/p/3ad5373465fd
代码,使用了递归:(特别要注意第21, 22行的代码:经常在这个地方把逻辑写复杂了)
def mergesort(arr):
if len(arr) <= 1:
return arr
middle = len(arr) // 2
left = mergesort(arr[:middle])
right = mergesort(arr[middle:])
return merge(left, right)
def merge(left, right):
C = []
li = 0
ri = 0
while (li < len(left) and ri < len(right)):
if left[li] < right[ri]:
C.append(left[li])
li += 1
else:
C.append(right[ri])
ri += 1
C += left[li:]
C += right[ri:]
return C
if __name__ == '__main__':
A = [5, 3, 6, 1, 2, 8, 2, 0, 10, 3, 4]
print(mergesort(A))
代码,不使用递归:
def mergesort(arr):
B = []
for i in range(0, len(arr)):
B.append([])
B[i].append(arr[i])
j = len(B)
while j > 1:
k = 0
B = B[:j]
for l in range(0, len(B) - 1, 2):
B[k] = merge(B[l], B[l + 1])
k += 1
if len(B) % 2 != 0:
B[k] = B[-1]
j = j // 2 + 1
else:
j = j // 2
return B[0]
def merge(left, right):
C = []
li = 0
ri = 0
while (li < len(left) and ri < len(right)):
if left[li] < right[ri]:
C.append(left[li])
li += 1
else:
C.append(right[ri])
ri += 1
C += left[li:]
C += right[ri:]
return C
if __name__ == '__main__':
A = [5, 3, 6, 1, 2, 8, 2, 0, 10, 3, 11]
print(mergesort(A))
python radix sort
见中文算法导论p100
python代码和讲解参考:🔗 [基数排序python实现 - sfencs - 博客园] https://www.cnblogs.com/sfencs-hcy/p/10616446.html
A = [125, 126, 642, 363, 10, 99, 512, 578, 999, 850, 193, 736, 74]
j = len(str(max(A)))
i = 0
while i <= j:
bucket = [[] for _ in range(0, 10)]
for item in A:
bucket[(item // (10 ** i)) % 10].append(item)
A.clear()
for x in bucket:
for v in x:
A.append(v)
i += 1
print(A)
Last Modified in 2023-04-13