178,981 questions
Advice
1
vote
0
replies
34
views
How do I make an authenticated request from my Next.js API on Supabase with RLS enabled?
In my case, I only want authenticated users to perform a SELECT query on my database, so I set up my RLS Policy for this scenario. This is where I am hitting an issue. With RLS enabled, I need to let ...
-1
votes
0
answers
41
views
Problem adding argument in the function with other default parameters [closed]
I am using PostgreSQL 18.0 and I have written a function with default parameters which inserts movie into the table. However, when I add the argument which must be added, it gives error:
SQL Error [...
1
vote
1
answer
62
views
Odd problem with PostgreSQL schema privileges
I have a regression test for a PostgreSQL database that checks to make sure a particular user cannot self-assign additional privileges to a particular schema. I do this by logging in as the user "...
1
vote
0
answers
29
views
Inserting into text array column when using unnest() [duplicate]
I have a table with the follow definition:
CREATE TABLE "test" (
id UUID PRIMARY KEY,
created TIMESTAMPTZ NOT NULL,
description TEXT,
permissions TEXT[]
);
I want to bulk ...
0
votes
1
answer
42
views
Why does `.WithInitScripts` not run my SQL files?
Description
I am using a test Postgres container (from testcontainers) for more accurate integration tests. To prevent repeating code, I want to use my existing SQL migration files to setup the ...
2
votes
1
answer
48
views
Self-signed certificate error when forcing SSL connecting to RDS PSQL
Hoping to get yalls help on the issue I am now sort of desperate about
Context:
I am deploying a docker container on EC2 Ubuntu, where it is used by two images - one for my Prisma-NestJs-based API and ...
-3
votes
0
answers
48
views
Error in PostgreSQL when running Rails and PostgreSQL using Docker Compose [closed]
I'm running Docker Compose on Ubuntu 24, and when accessing PostgreSQL from within the backend container, I get the following error:
root@60128607c5ab:/backend# psql -p 5433 -U postgres
psql: error: ...
2
votes
1
answer
39
views
Jooq get sequence increment
Maybe there's an easier way to get the Increment with JOOQ?
This one looks more like a crutch:
int increment =
Optional.ofNullable(CUSTOMER_ID_SEQ.getIncrementBy())
.map(Field::getName)
...
-2
votes
1
answer
107
views
How to display in postgresql only the records that are not within the 10 minutes [closed]
For example, I have this table below, how can I display only the records that aren't in the 10 minutes range. In this example should return the first and last in note examples
user_id | ...
-2
votes
0
answers
65
views
The Rails console is trying to connect to PostgreSQL via Docker and is giving an error [closed]
I'm trying to access PostgreSQL from within my backend application using Docker, but I'm getting the following error:
User.last
#=> There is an issue connecting to your database with your username/...
1
vote
1
answer
74
views
Creating Materialized view in PG 17 ignores data types in SELECT
I have the following SQL to create a materialized view and the SQL seems reasonable to me but it's unclear from Postgres docs what should happen in this case.
I am listing the columns when creating ...
4
votes
3
answers
141
views
Regex function to extract numbers from string-type values, separated by "-", to get the difference of each two values
I'm 100% new to Regex so I've been floundering about on regex101 trying to figure out how to get my desired output. I am using PostgreSQL to write a query to extract a set of values from the string. ...
-3
votes
0
answers
48
views
Can't create a Postgres database with .NET Aspire
Was trying to create a database (retmarkdb), but only datatabase "postgres" (with password 'retmark123') is created.
// RetmarkApp.AppHost/AppHost.cs
var builder = DistributedApplication....
1
vote
0
answers
46
views
How to inject dynamic PostgreSQL SET parameters (tenant_id) before every Superset query for multi-tenancy?
I am integrating a Superset dashboard into my web application and need multi-tenant behavior where every client sees the same dashboard layout but only the data that belongs to them. My backend ...
-1
votes
0
answers
52
views
Supabase server refusing to start locally because of migrations mismatch
I am new to supabase I need help starting my supabase server locally
I'm working on a project that was initially started with Lovable AI and uses Supabase as it's backend. I recently joined the team ...
-1
votes
0
answers
29
views
prisma p1001 error - Can't reach database server at `aws-1-ap-south-1.pooler.supabase.com:5432`
This is the schema in my prisma.schema:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
...
Advice
1
vote
3
replies
38
views
Safe to run "VACUUM FREEZE" on template1 or template0 databases in postgres?
I run periodic VACUUM FREEZE on my main database to avoid aggressive vacuuming during busy times, wondering if it's safe to run freeze on template databases too before they reach the threshold (200M ...
1
vote
0
answers
73
views
DB query execution hanging in golang
I don’t understand why this is happening. I’m using the Go database package to connect to a PostgreSQL database. I loop through fullmsg (88 messages), but after processing about 27 messages, ...
-3
votes
0
answers
19
views
Why does READ COMMITTED allow Phantom Reads in PostgreSQL? [migrated]
When writing SQL queries against a large PostgreSQL database, I am seeing phantom reads despite setting the transaction isolation level to READ COMMITTED. Can you provide a concrete example of a multi-...
-4
votes
0
answers
27
views
Dockerize backend ExpressJS made with sequelize [closed]
I'm trying to fully Dockerize my application, which includes:
Next.js (frontend)
Express.js (backend)
PostgreSQL
Sequelize ORM for models and migrations
my backend can't connect to the PostgreSQL ...
Best practices
0
votes
3
replies
55
views
Compare fingerprints with a set of 10*10^6 other audio fingerprints in postgres
So I have a function that I used to compare audio fingerprints with a few thousand audio fingerprints stored in a postgresql. What I did basically was:
def my_function(cur: Cursor, threshold: ...
-4
votes
1
answer
50
views
PG::InsufficientPrivilege error using Digital Ocean's App Platform and a connected dev database for a Rails 8 app
I have a Rails 8 application using an attached dev database and I am deploying to the Digital Ocean App Platform. I can successfully build the application and when I get to the deploy step I see this ...
1
vote
2
answers
63
views
PostgreSQL: connection was terminated due to conflict with recovery on primary node when running SELECT … FOR UPDATE
I have a PostgreSQL cluster with 1 primary and 1 streaming-replica standby. Occasionally I get the following JDBC exception on the primary node, not the standby:
SELECT \* FROM orders WHERE id IN (?) ...
1
vote
5
answers
86
views
Grouping rows, and then deleting only a sub range (based on their dates) from each of those groups
I use Postgres on my web server in order to record incoming queries into a table calls2, basically writing a single row each time with lots of repeating information, such as a date field ("when&...
1
vote
1
answer
61
views
Slow TimescaleDB lookup on indexed column (event_key) without a time filter
I'm using a self-hosted TimescaleDB instance to store logs. I have a hypertable logs that is partitioned by the timestamp column.
I need to perform a fast lookup query based on the event_key column, ...