Open ndrean opened 1 week ago
PostgREST
is a standalone web server that automatically turns your PostgreSQL
database into a RESTful API. It reads your database schema and creates a full set of CRUD endpoints without requiring you to write any code.
It stands between the Phoenix backend and the PostgreSQL database and exposes endpoints. It may need an SSL connection between PostgreSQL and PostgREST, whilst the Phoenix server and the PostgREST container are probably in the same VPC. A special role will be setup for PostgREST in PostgreSQL.
flowchart TD
subgraph Phoenix["Phoenix App (4000)"]
PC[PostgrestClient]
end
subgraph PostgREST["PostgREST Server (3000)"]
PRM[Pool Connection Manager]
PRM -->|manages| CP[Connection Pool]
end
subgraph PostgreSQL["PostgreSQL Server (5432)"]
PG[(Database)]
end
PC -->|HTTP Requests| PRM
CP -->|DB Connections| PG
style Phoenix fill:#a8e6cf
style PostgREST fill:#dcedc1
style PostgreSQL fill:#ffd3b6
PostGIS extends the capabilities of the PostgreSQL relational database by adding support for storing, indexing, and querying geospatial data.
PostGIS features include:
Spatial Data Storage: Store different types of spatial data such as points, lines, polygons, and multi-geometries, in both 2D and 3D data.
Spatial Indexing: Quickly search and retrieve spatial data based on its location.
Spatial Functions: A wide range of spatial functions that allow you to filter and analyze spatial data, measuring distances and areas, intersecting geometries, buffering, and more.
Geometry Processing: Tools for processing and manipulating geometry data, such as simplification, conversion, and generalization.
Raster Data Support: Storage and processing of raster data, such as elevation data and weather data.
Geocoding and Reverse Geocoding: Functions for geocoding and reverse geocoding.
Integration: Access and work with PostGIS using third party tools such as QGIS, GeoServer, MapServer, ArcGIS, Tableau.
only connected clients that LISTEN will receive a message. This is not a message queue.
when a NOTIFY is executed inside a transaction, the notify events are not delivered until and unless the transaction is committed.
Postgres doc [TODO]
The
citext
extension in Postgres provides a case-insensitive data type for text. This is particularly useful in scenarios where the case of text data should not affect queries, such as usernames or email addresses, or any form of textual data where case-insensitivity is desired.
psql
is a terminal-based front-end to PostgreSQL
. It enables you to type in queries interactively, issue them to PostgreSQL, and see the query results.
pgbouncer
is a PostgreSQL connection pooler. Any target application can be connected to pgbouncer
as if it were a PostgreSQL
server, and pgbouncer
will create a connection to the actual server, or it will reuse one of its existing connections.
The aim of pgbouncer
is to lower the performance impact of opening new connections to PostgreSQL
.
This can happen when many applications reach the database, more than the database is supposed to support. This can be true in a Kubernetes environment.
In order not to compromise transaction semantics for connection pooling, pgbouncer
supports several types of pooling when rotating connections:
Session pooling Most polite method. When a client connects, a server connection will be assigned to it for the whole duration the client stays connected. When the client disconnects, the server connection will be put back into the pool. This is the default method.
Transaction pooling A server connection is assigned to a client only during a transaction. When PgBouncer notices that transaction is over, the server connection will be put back into the pool.
Statement pooling Most aggressive method. The server connection will be put back into the pool immediately after a query completes. Multi-statement transactions are disallowed in this mode as they would break.
In the migration:
CREATE EXTENSION cube;
CREATE EXTENSION earthdistance
pg_cron
You have to add it to your image the installer postgresql-17-cron if you build a Debian
image.
FROM postgres:17.1-bookworm
RUN apt-get update && \
apt-get -y install postgresql-17-cron && \
apt-get clean \
&& rm -rf /var/lib/apt/lists/*
[TODO] Command ?? to run Postgres and set the "postgresql.conf" config for cron.database_name = 'postgres'
and shared_preload_libraries = 'pg_cron'
.
and put this in the migration:
CREATE EXTENSION pg_cron;
GRANT USAGE ON SCHEMA cron TO ??? <---
[TODO]: test this
Add to the Debian image:
apt install postgresql-17-http
And migration:
CREATE EXTENSION http;
[TODO]: test this
The migration:
CREATE EXTENSION tablefunc;
pg_config
is in your PATH (import for Docker image)CREATE EXTENSION pg_background;
After watching this video:
https://www.postgresql.org/docs/17/contrib.html
https://github.com/dhamaniasad/awesome-postgres?tab=readme-ov-file#extensions
[TODO]
trunk
?