Skip to content

Postgresql

Docker Compose

yaml
services:
  postgres:
    image: postgres
    environment:
      POSTGRES_PASSWORD: "postgres"
    ports:
      - "5432:5432"

TIP

user: postgres

password: postgres

K8s Operator

CloudNativePG

The best way to deploy a database on k8s, including best practices and backup.

CloudNativePG

Partition on String Column

sql
with cte as (
select abs(mod(hashtext("COLUMN"),5)) as partition_group,
	   *
  from people
)
select count(partition_group), partition_group 
  from cte 
 group by partition_group
 order by 2

Result on 2 milion rows and 5 partitions:

countpartition_group
4005350
3990901
4006912
4003763
3993084

Feel free to use any content here.