Skip to content

Instantly share code, notes, and snippets.

@luhn

luhn/README.md Secret

Last active August 25, 2016 18:40
Show Gist options
  • Save luhn/e09522d524354d96d297b153d1479c13 to your computer and use it in GitHub Desktop.
Save luhn/e09522d524354d96d297b153d1479c13 to your computer and use it in GitHub Desktop.

This is the result of repeatedly entering query.sql into PSQL and running smem or free after each iteration and copying the relevant line from top. The PSQL connection is kept open throughout the process; smem and free are run in separate terminals.

~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.3G 2.5G 213M 96M 4.9G
-/+ buffers/cache: 251M 7.6G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.3G 2.5G 213M 96M 4.9G
-/+ buffers/cache: 322M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.3G 2.5G 213M 96M 4.9G
-/+ buffers/cache: 322M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.3G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 328M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.3G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 329M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.3G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 329M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 342M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 349M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 349M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 349M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 349M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 354M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 355M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 355M 7.5G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 357M 7.4G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 357M 7.4G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 357M 7.4G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 357M 7.4G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 357M 7.4G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 357M 7.4G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 357M 7.4G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 357M 7.4G
Swap: 0B 0B 0B
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 357M 7.4G
Swap: 0B 0B 0B
SELECT reservation.id,
array_agg(guest.id) AS guest_ids
FROM reservation
JOIN guest ON guest.id = reservation.guest_id
WHERE reservation.guest_id IN (
SELECT id
FROM guest
WHERE (guest.mobile_phone_num LIKE '713%'
OR guest.home_phone_num LIKE '713%'
OR guest.work_phone_num LIKE '713%')
AND venue_id = 532
AND hidden = FALSE
)
GROUP BY reservation.id
LIMIT 20;
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.3G 2.5G 213M 95M 4.9G
-/+ buffers/cache: 253M 7.5G
Swap: 0B 0B 0B
~$ sudo -u postgres smem -trs uss
PID User Command Swap USS PSS RSS
9271 postgres /usr/lib/postgresql/9.3/bin 0 56364 64201 74592
12857 postgres /usr/bin/python /usr/bin/sm 0 5840 6261 7460
12850 postgres postgres: postgres souschef 0 1368 1856 3800
9276 postgres postgres: autovacuum launch 0 784 1156 2972
9277 postgres postgres: stats collector p 0 300 469 1868
9273 postgres postgres: checkpointer proc 0 148 341 1876
9275 postgres postgres: wal writer proces 0 140 321 1808
9274 postgres postgres: writer process 0 132 6971 15144
-------------------------------------------------------------------------------
8 1 0 65076 81576 109520
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 1368 1856 3800
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 193460 197242 202824
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 200560 204342 209924
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 200616 204412 210016
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 207440 211222 216804
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 207440 211222 216804
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 214296 218078 223660
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 214296 218078 223660
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 214492 218274 223856
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 221132 224914 230496
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 221332 225114 230696
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 227380 231162 236744
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 227428 231210 236792
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ sudo -u postgres smem -trs uss | grep souschef
12850 postgres postgres: postgres souschef 0 233580 237362 242944
~$ free -h
total used free shared buffers cached
Mem: 7.8G 5.4G 2.4G 213M 96M 4.9G
-/+ buffers/cache: 356M 7.4G
Swap: 0B 0B 0B
~$ ps aux | grep souschef
ubuntu 13447 0.0 0.0 99232 4200 pts/4 S+ 11:34 0:00 /usr/lib/postgresql/9.3/bin/psql -U postgres souschef
postgres 13455 0.3 2.9 2378920 242944 ? Ss 11:34 0:00 postgres: postgres souschef [local] idle
ubuntu 13472 0.0 0.0 10460 944 pts/1 S+ 11:38 0:00 grep --color=auto souschef
~$ top
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
13455 postgres 20 0 2273116 3796 1596 S 0.0 0.0 0:00.00 postgres
13455 postgres 20 0 2378968 201200 135296 S 0.0 2.5 0:00.11 postgres
13455 postgres 20 0 2378920 208260 135296 S 0.0 2.5 0:00.18 postgres
13455 postgres 20 0 2378920 214904 135296 S 0.0 2.6 0:00.24 postgres
13455 postgres 20 0 2378920 221780 135296 S 2.3 2.7 0:00.31 postgres
13455 postgres 20 0 2378920 241364 135296 S 0.0 3.0 0:00.37 postgres
13455 postgres 20 0 2378920 242944 135296 S 0.0 3.0 0:00.43 postgres
13455 postgres 20 0 2378920 242944 135296 S 0.0 3.0 0:00.49 postgres
13455 postgres 20 0 2378920 242944 135296 S 0.0 3.0 0:00.55 postgres
13455 postgres 20 0 2378920 242944 135296 S 0.0 3.0 0:00.62 postgres
13455 postgres 20 0 2378920 242944 135296 S 0.0 3.0 0:00.68 postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment