Skip to content

Instantly share code, notes, and snippets.

View zhjwpku's full-sized avatar
🦀

Junwang Zhao zhjwpku

🦀
View GitHub Profile
@zhjwpku
zhjwpku / citus_cheatsheet.sql
Last active November 9, 2023 04:33 — forked from sfriquet/citus_cheatsheet.sql
Citus Cheatsheet
-- Set number of shard
ALTER DATABASE citus SET citus.shard_count = 64;
-- distribute the table
SELECT create_distributed_table('github_events', 'repo_id');
-- undo that and make it local again
SELECT undistribute_table('github_events');
-- change distribution column
@zhjwpku
zhjwpku / gpdb_dev_enviroment_ubuntu22.04.sh
Last active March 24, 2023 01:50
Setup a dev enviroment for gpdb.
sudo apt update
sudo apt upgrade
sudo apt install -y zsh neovim
## set ecs-user / hellogpdb
sudo passwd ecs-user
## make ecs can access github
sudo bash -c bash
echo "140.82.114.4 github.com" >> /etc/hosts
@zhjwpku
zhjwpku / gpdb_tpch_zlib.sql
Created October 4, 2022 05:06
Greenplum tpch zlib compression test.
CREATE TABLE customer_zlib (
c_custkey integer NOT NULL,
c_name character varying(25) NOT NULL,
c_address character varying(40) NOT NULL,
c_nationkey integer NOT NULL,
c_phone character(15) NOT NULL,
c_acctbal numeric(15,2) NOT NULL,
c_mktsegment character(10) NOT NULL,
c_comment character varying(117) NOT NULL
) with (appendoptimized=true, compresstype=zlib, orientation=column) distributed by (c_custkey);
@zhjwpku
zhjwpku / gpdb_tpch_zstd.sql
Created October 4, 2022 05:05
Greenplum tpch zstd compression test.
CREATE TABLE customer_zstd (
c_custkey integer NOT NULL,
c_name character varying(25) NOT NULL,
c_address character varying(40) NOT NULL,
c_nationkey integer NOT NULL,
c_phone character(15) NOT NULL,
c_acctbal numeric(15,2) NOT NULL,
c_mktsegment character(10) NOT NULL,
c_comment character varying(117) NOT NULL
) with (appendoptimized=true, compresstype=zstd, orientation=column) distributed by (c_custkey);
@zhjwpku
zhjwpku / gpdb_tpch_lz4.sql
Created October 4, 2022 05:01
Greenplum tpch lz4 compression test.
CREATE TABLE customer_lz4 (
c_custkey integer NOT NULL,
c_name character varying(25) NOT NULL,
c_address character varying(40) NOT NULL,
c_nationkey integer NOT NULL,
c_phone character(15) NOT NULL,
c_acctbal numeric(15,2) NOT NULL,
c_mktsegment character(10) NOT NULL,
c_comment character varying(117) NOT NULL
) with (appendoptimized=true, compresstype=lz4, compresslevel = 1, orientation=column) distributed by (c_custkey);
@zhjwpku
zhjwpku / pg_buffercache.sql
Last active July 2, 2022 13:04
pg_buffercache usage
create extension pg_buffercache;
-- 查看哪个数据库占用的缓存最多
select datname, count(*), count(*) filter (where isdirty = true) as dirty
from pg_buffercache as b, pg_database as d
where d.oid = b.reldatabase
group by rollup (1);
-- 查看指定数据库中哪张表占用的缓存最多
select relname, relkind, count(*), count(*) filter (where isdirty = true) as dirty
public class MaxNumString {
public int Continumax(String intputStr, StringBuffer outputStr){
int maxlength=0;
StringBuffer maxNumberStr = null;
int nowlength=0;
StringBuffer nowNumberStr = null;
for(int i=0;i<intputStr.length();i++){
import java.util.Scanner;
public class Jiepijiu {
public static void main(String [] args) {
int w[] = new int[10010];
int lastw[] = new int[10010];
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int time = 0;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Josephus {
public static List<Integer> getResult(int n, int m) {
List<Integer> circle = new ArrayList<>();
for (int i = 1; i <= n; i++) {
circle.add(i);