This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://jumpcloud.com/blog/how-to-upgrade-ubuntu-20-04-to-ubuntu-22-04 | |
https://askubuntu.com/questions/1098480/attempting-to-upgrade-from-ubuntu-server-16-04-to-18 | |
https://gitlab.com/gitlab-com/gl-infra/production-engineering/-/issues/13273 | |
https://aws.amazon.com/blogs/database/manage-collation-changes-in-postgresql-on-amazon-aurora-and-amazon-rds/ | |
https://www.youtube.com/watch?v=0E6O-V8Jato | |
Sorting Out glibc Collation Challenges: Joe Conway - PGCon 2023 | |
glibc upgrades from 2.27 to 2.31, which changes the ordering |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.enterprisedb.com/blog/partitioning-large-table-without-long-running-lock | |
create table orig_table | |
( id int generated always as identity not null, | |
data float default random() | |
); | |
create index orig_data_index on orig_table(data); | |
create index orig_id_index on orig_table(id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALL VIA | |
apt-get -- 10.14-0ubuntu0.18.04.1 | |
homebrew -- stable 12.4 | |
brew install postgresql@11 | |
aws RDS -- major version 12 | |
aws RDS Aurora | |
single-master 9.6.18 10.13 11.8 | |
global 10.13 11.8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgres=# create table t(col1 int, col2 int); | |
CREATE TABLE | |
Time: 3.670 ms | |
postgres=# insert into t select x,x from generate_series(1, 1000000) x; | |
INSERT 0 1000000 | |
Time: 3495.578 ms (00:03.496) | |
postgres=# select 't'::regclass::oid; | |
oid | |
------- | |
16395 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgresql developer options are a list of configs users can play with in the sandbox environment for debugging. | |
i used it to study various locks taken when a statement is executed on an object | |
just to get things started, there is a GUC where one can enable lock tracing on a particular table only | |
this is cool as i dont care what else is going on in the system otherwise, but i want to learn what locks are taken by what sql statements | |
infact one can make use of https://pglocks.org/ to run the various statements on this site (by hussein) and understand the locks taken | |
these would be very useful when one is doing migrations on large objects which are blocking in nature | |
https://github.com/ankane/strong_migrations (is a good collection of those cases and the links to the blogs) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#this is mimicking https://github.com/postgres/postgres/blob/a68159ff2b32f290b1136e2940470d50b8491301/src/test/modules/xid_wraparound/t/002_limits.pl | |
#but many times users dont look at source code, so these examples are missed | |
``` | |
./configure --prefix=/opt/postgresql --with-openssl --enable-debug --enable-profiling --enable-cassert --enable-tap-tests CFLAGS="-ggdb -Og -g3 -fno-omit-frame-pointer -DLOCK_DEBUG -DBTREE_BUILD_STATS -DWAL_DEBUG " | |
make | |
cd /home/ubuntu/github/postgres/src/test/modules/xid_wraparound | |
make check PG_TEST_EXTRA='xid_wraparound' | |
sudo make install | |
sudo chown -R postgres:postgres /opt/postgresql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
many times there are tables with 10s of references in other tables. when we try to delete data cascade, sometimes deletes are very slow. | |
we have an index on the column of the primary table and some of the foreign tables, but we dont know why the delete is slow. | |
here we try to make use of auto_explain with gucs to track plans of foreign tables to figure out slow deletes and how we fix them | |
postgres@ubuntu:/tmp$ cat db1/postgresql.auto.conf | grep -v '^#' | |
port=5432 | |
session_preload_libraries = auto_explain | |
auto_explain.log_min_duration = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgres@ubuntu:/tmp$ psql -p 5432 | |
psql (16.4 (Ubuntu 16.4-0ubuntu0.24.04.1)) | |
Type "help" for help. | |
postgres=# create database demo; | |
CREATE DATABASE | |
postgres=# \c demo | |
You are now connected to database "demo" as user "postgres". | |
demo=# select * from pg_database; | |
demo=# select oid,datname from pg_database; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgres=# create table t(col1 int primary key, col2 int, col3 int); | |
CREATE TABLE | |
postgres=# create table r(col4 int primary key, col1 int references t(col1) on update cascade on delete cascade); | |
CREATE TABLE | |
postgres=# insert into t select x,x,x from generate_series(1, 1000000) x; | |
insert into r select col1, 1+ col1 % 10 from t; | |
INSERT 0 1000000 | |
INSERT 0 1000000 | |
postgres=# create table to_be_deleted as select col1, null::int as col2 from t where col2 % 9 = 3; | |
SELECT 111111 |
NewerOlder