Questions tagged [postgresql-13]

Use this tag to indicate that your question is about PostgreSQL version 13. Questions concerning database administration should go to https://dba.stackexchange.com/

368 questions
3
votes
2 answers

Postgresql is not using indexes if I use search text with 5 characters. With 6 it works. Why?

I'm using Postgresql 13. With this query PostgreSQL is using the indexes: SELECT * FROM "players" WHERE team_id = 3 AND ( code ILIKE 'lushij' OR REPLACE(lastname||firstname,' ','') ILIKE '%lushij%' OR…
Fred Hors
  • 3,258
  • 3
  • 25
  • 71
2
votes
1 answer

SQL count and filter query optimization

Given a database table article_bookmarks with columns userId and articleId, if a user bookmarks an article a table entry (userId, articleId) with respective ids is made. I want to retrieve the total number of users that bookmarked a specific article…
DaHoC
  • 314
  • 1
  • 4
  • 14
2
votes
1 answer

Postgres is taking too long to attach partition to a table. Want to understand why

I have a table T1(non-partitioned). Size of T1 is approx 4TB. I have created another table T2(partitioned table). Now I want to attach T1 as child table of T2. So I am running below query to achieve the same. ALTER TABLE T1 ADD CONSTRAINT…
cyborg__
  • 23
  • 5
2
votes
0 answers

Scalable approach to calculating balances over thousands of records in PostgreSQL

I'm facing the challenge of generating 'balance' values from thousands of entries in a PG table. The rows in the table have many different columns, each useful in calculating that rows contribution to the balance. Each row/entry belongs to some…
Alechko
  • 1,406
  • 1
  • 13
  • 27
2
votes
1 answer

why POSTGRES database uses postgres user as superuser/default user ? how to change it?

we are planning to install postgresql-13 on our production cluster. but as we have postgres as default user , i want to remove it and use superuser of prod cluster. can any on suggest how to install psql-13 with prod superuser as a default user…
rishikanth
  • 21
  • 1
2
votes
1 answer

Why doctrine migrations ignore my index declaration?

I would like to create a table with an indexed columned to speed up searches. Here is a sample: #[ORM\Entity(repositoryClass: SettingRepository::class)] #[ORM\Table(name: '`tr_setting`', indexes: [ new ORM\Index(columns: ['code'], name:…
2
votes
1 answer

Convert rows into json object in postgresql

With PostgreSQL 13 I'm trying to convert rows with 2 columns into a JSON object where a column value is the key and the other column is the value. My table: key | value -------- | -------- key1 | value1 key2 | value2 …
cadolbeau
  • 65
  • 6
2
votes
1 answer

AWS EC2 Amazon Linux 2 AMI PostgreSQL Installation

Have an AWS EC2 instance which is running Amazon Linux AMI 2. Like to install PostgreSQL Server 13 on it. Following the instructions as mentioned here - https://www.postgresql.org/download/linux/redhat/ But, when executing - sudo yum install -y…
2
votes
2 answers

sqlalchemy and asyncpg – set postgres statement_timeout

When doing engine: AsyncEngine = create_async_engine(...) and then async with engine.connect() as conn: result: Result = await conn.execute(text("""...""")) I would like to specify a timeout. Ideally I'd be able to set statement_timeout just…
scravy
  • 11,904
  • 14
  • 72
  • 127
2
votes
0 answers

Azure Database for PostgreSQL - Admin user access issue

I have created new Azure database for PostgreSQL - Flexible Server with admin user as "admin_demo". Now after creating database I have done followoing steps: create schema abc authorization admin_demo; -- creates new schema. create role…
2
votes
0 answers

How to deal with django migration postgres deadlock?

So, I was deploying the django app to production and then the infamous postgres deadlock situation happened. This happens during the django migration. Django version: 3.2 Postgres 13 Google cloud sql postgres. OperationalError deadlock…
Maverick
  • 2,738
  • 24
  • 91
  • 157
2
votes
0 answers

GCP - size of CloudSQL Postgres Database logs are increasing rapidly and are not being purged

I'm currently working with Cloud SQL to store data for my database, which is around 14GB in size. However, over monitoring for the past few weeks, it seems like the storage capacity of the database has been continually increasing. When looking at…
2
votes
1 answer

How can I improve this query without HAVING Clause

There's two tables: users documents users: CREATE TABLE IF NOT EXISTS users ( id SERIAL PRIMARY KEY, username TEXT NOT NULL UNIQUE ) documents: CREATE TABLE IF NOT EXISTS documents ( id SERIAL PRIMARY KEY, …
Ulvi
  • 965
  • 12
  • 31
2
votes
1 answer

Postgresql - store only hours and minutes in column time type

There is some option to store only hours and minutes in the database (No seconds)? I know that I can use the function to_char in my query, but this is not the solution for me. I am using/editing a system written in PHP that I cannot edit (I mean…
LordF
  • 407
  • 5
  • 18
2
votes
1 answer

postgresql-13-postgis-3 : Depends: libgdal20 (>= 2.0.1) but it is not going to be installed

I am trying to install the postgresql-13-postgis-3 package using following method on ubuntu 18.04 version. I have tried following method, sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >>…
Tek Kshetri
  • 2,129
  • 1
  • 17
  • 41
1 2
3
24 25