178,965 questions
0
votes
0
answers
23
views
Does slick-pg support this PostgreSQL feature?
Using the PostgreSQL-specific slick-pg extension of slick, which supports multi-upsert. Let's consider a small example.
CREATE TABLE foo (id INT PRIMARY KEY, name TEXT DEFAULT 'foo');
The ...
1
vote
0
answers
45
views
Pulling schema updates from Postgres
I have few node microservices connected to single postgres db. I also have an elixir service for realtime message passing between BE and FE.
I am now enhancing realtime service with some additional ...
-2
votes
0
answers
50
views
running the node micro services in local with DB postgres using docker [closed]
UPDATE 1:
I searched in the codebase and I am seeing in the below files, can you please let me know where to update, since I am a beginner not sure where to update the port 5432, providing the image ...
Best practices
2
votes
4
replies
112
views
What Considerations should I make with "SELECT ..." queries to avoid data changes
Relatively new to SQL and want to learn best practices for "safe" queries.
If I have queries like "SELECT {cols} FROM {table} WHERE {condition}" or SELECT {cols} FROM ...
0
votes
1
answer
120
views
Why is DELETE much slower than TRUNCATE even when deleting all rows from a table in PostgreSQL?
In an application cleanup job, I need to remove all rows from a table regularly.
Table:
CREATE TABLE session_logs (
id BIGSERIAL PRIMARY KEY,
session_id TEXT,
created_at TIMESTAMPTZ, ...
13
votes
3
answers
674
views
PostgreSQL prepared statement becomes slower after repeated executions because the optimal plan changes
I'm debugging a performance regression in an application that uses prepared statements against PostgreSQL 15.
I have a table with skewed data distribution:
CREATE TABLE invoice_events
(
id ...
Advice
0
votes
1
replies
55
views
CIS Postgres 15 Benchmarks - log_replication_commands
As an action of our last test my company implemented log_replication_commands to 'log all replication commands that are executed in your database cluster to ensure the data is not off-loaded to an ...
3
votes
1
answer
98
views
Advance `confirmed_flush_lsn` in PostgreSQL 18 without a heartbeat table when `pgoutput` skips empty transactions
After upgrading to PostgreSQL 18, pgoutput no longer sends BEGIN/COMMIT for transactions that touch only tables outside the publication. This is by design (see related question). Our replication slot'...
2
votes
1
answer
66
views
Implementing ToSql and FromSql for a composite Postgres type with fields with Diesel
So I have a "user" composite type in Postgres:
CREATE TYPE "user" AS (
username varchar(20),
password text
);
Used to have a field
CREATE TABLE foo (
...
users ...
Best practices
13
votes
12
replies
2k
views
I built a database. What should I do next?
I built a small relational database as a personal learning project. It is around 10,000 lines of code and already includes many of the core parts of a basic relational database, such as page-based ...
-8
votes
0
answers
154
views
Integration of cursor project code to Supabase
[enter image description here][1]
I have been trying to connect my Supabase to my cursor project and for that I ran the SQL code shown below in the SQL editor of Supabase.
My code from cursor:
--
...
-1
votes
0
answers
24
views
How to add a new slave with PostgreSQL v17 to replicate from old master with PostgreSQL v16 [migrated]
I have a set of 4 servers that currently have PostgreSQL v16, one of them works as master, the other 3 as slave. I am trying to add a 5th server that ideally runs PostgreSQL v17. I tried to use ...
Best practices
2
votes
7
replies
123
views
Passing columns as function arguments (paired)
I'm calling a function with "paired" arguments:
WITH ts AS (
SELECT t.c1, t.c2
FROM t
)
-- `ORDER BY` to guarantee the same order
SELECT f(
a => ARRAY( SELECT ts.c1 FROM ts ...
Best practices
0
votes
0
replies
55
views
Audit table: efficient query for recent rows when filtering on non-partition column of TimescaleDB hypertable
I have an audit table using a TimescaleDB hypertable:
CREATE TABLE log.data
(
modified timestamptz not null default clock_timestamp(),
table_schema text not null,
table_name text not ...
0
votes
1
answer
129
views
Duplicated data from a select [closed]
I'm creating a function in Postgresql to bring data based on the user's name, but when I don't pass a name in the argument it should bring all the appointments independent of the name, but I'm getting ...