Recently I found a Bug of Postgres, to fully understand it and fix it, I spend some time on Postgres operator class and operator family concepts. I find it very similar to SML’s module system. So this blog records my thoughts.
Continue readingMotion deadlock and all related things in Greenplum
Recently I am busy with some escalations on lateral join in Greenplum. During the process of studying the related code and issues, many problems intertwine. These are common issues in an MPP database.
A more recent blog should be better: Interconnect Deadlock Problem in Greenplum.
Continue readingReading Notes: The Little Typer — first half
Yet another little book

The great book is written by Prof. Daniel P. Friedman and
David Thrane Christiansen, the website is The Little Typer. It introduces dependent type using a small language, Pie.
I am perusing this book since the Spring Festival and writing the thoughts and my understand here.
Continue readingDistributed Lock in Greenplum
I have been working on locks in Greenplum since first half of 2018. The related projects are: Global Deadlock Detector, lock mode optimization and other minor things. This blog reviews all the lessons that learned.
Continue readingAnalysis of the number of swapping in partition of Quicksort
Quicksort is an elegant and efficient sorting algorithm. Analysis of quick sort is a lot of fun. The core part of quick sort algorithm is partition the original array into two parts. This part of code is shown below (in java):
private void quicksort(int[] a, int lo, int hi) {
if (hi <= lo) return;
int i = lo - 1, j = hi;
int t, v = a[hi];
while (true) {
while (a[++i] < v);
while (v < a[--j])
if (j == lo) break;
if (i >= j) break;
t = a[i]; a[i] = a[j]; a[j] = t;
}
t = a[i];
a[i] = a[hi];
a[hi] = t;
quicksort(a, lo, i - 1);
quicksort(a, i + 1, hi);
}
Understand distkey in Greenplum
Greenplum database is the world’s leading open-source MPP database. MPP database means a distributed system. They very first thing you have to deal with in distributed system is that how to divide data into pieces and split them around machines. Greenplum supports different kinds of data distribution policy: hash, random, replicated. Among these kinds of policy, hash-distribution is the most important one since many intermediate results are hash-distributed. Please visit https://greenplum.cn/ for more details.
Continue readingDijkstra via SQL: a glance at Recursive CTE
Computer science might be said born at 1930s, in the math college of Princeton University. Church, Turing, Gödel independently discovered the root of computer science:
- Lambda Calculus
- Turing Machine
- Gödel incompleteness theorem
They all relates to the problem: self reference or self description. We might call it recurrence too.
Continue readingOn dynamic hash expansion
Dynamic hash table will expand when it is full. If we simply use modulo to map hash value to the entry position, there are some properties on the data movement while expanding.
Let’s start with some questions:
- If at the very first, the table size is n, and for the entry at ith place ( k \mod n = i), what is the possible place for it after expanding?
- Can we describe the moving process?
Coupon collector’s problem:An infinite-series perspective
Background
If you are not familiar with Coupon collector’s problem, please first read the following page:
Six years ago when I was in graduate school, I encountered this problem. I did not want to use Indicator variable method to solve it, so I tried my best to solve it using infinite series. I came up with a complicated formula which was not accurate and I am not satisfied because this means it is wrong.

锅哥的12小时飓风赛复盘
4月12日参加了第一次斯巴达12小时的飓风赛,反正是完成了,比较虐。想求得的答案也求得了。下面讲细细的回味这个完整过程的来龙去脉。
从《士兵突击》开始
2017~2018的春节,我看了《红海行动》,还挺喜欢的,然后看影评有人说挺多《士兵突击》剧组出来的,比如张译,然后发现《士兵突击》有人可以刷十几遍。顿时来了兴趣,然后就入了兰晓龙的坑,也开始一遍遍刷《士兵突击》和《我的团长我的团》。
Continue reading