Category "postgresql"

Best way to maintain an ordered list in PostgreSQL?

Say I have a table called list, where there are items like these (the ids are random uuids): id rank text --- ----- ----- x 0 Hello x 1 World x

Deadlock involving SELECT FOR UPDATE

I have transaction with several queries. First, a select rows with FOR UPDATE lock: SELECT f.source_id FROM files AS f WHERE f.component_id = $1 AND f.a

postgresql sequence getting max_value

How to get max_value and min_value Postgres sequence? I created the sequence using this statement create sequence seqtest increment 1 minvalue 0 maxvalue 20;

Restoring database delta between two dumps

We're currently struggling with moving our Aurora Database to an RDS Postgres DB. Our database is quite huge with 80GB and some tables having up to 85 million e

Postgresql - SQL query to list all sequences in database

I would like to select all sequences in the database, get the schema of sequence, dependent table, the schema of a table, dependent column. I've tried the follo

Why does Postgres still do a Bitmap Heap Scan when a covering index is used?

The table looks something like this: CREATE TABLE "audit_log" ( "id" int4 NOT NULL DEFAULT nextval('audit_log_id_seq'::regclass), "entity" varchar(50) COLLA

How do I convert numpy NaN objects to SQL nulls?

I have a Pandas dataframe that I'm inserting into an SQL database. I'm using Psycopg2 directly to talk to the database, not SQLAlchemy, so I can't use Pandas b

How to dump a postgres db excluding one specific table?

I'd like to use pg_dump to backup postgres database content. I only want to ignore one specific table containing cached data of several hundred GB. How could I

postgresql installation mac: Set the LC_ALL environment variable to a valid local

I am trying to install postgresql 9.6 using brew on my mac and get the below error whenever i start the server : FATAL: postmaster became multithreaded during

PostgreSQL ORDER BY with VIEWs

Let's say I want to write a simple SELECT query that uses a VIEW: CREATE TEMP VIEW people AS SELECT p.person_id ,p.full_name ,p.phone FROM person

How to define a default value for a column after a cast in a pgloader script?

Let's say I'm migrating a MySQL database to PostgreSQL with pgloader, using the default sample on the official website: load database from mysql://

How to remove reverse duplicates from a SQL query

Context: I have a select query where I have have link between devices. Some links have "reverse duplicates" that I would like to get rid of in the select query

django test app error - Got an error creating the test database: permission denied to create database

When I try to test any app with command (I noticed it when I tried to deploy myproject using fabric, which uses this command): python manage.py test appname

JPA ERROR: relation does not exist

I can't figure out what I'm doing wrong. I'm learning JPA mapping to a relational DB, by following some tutorials on the web, but can't find one that is straigh

Can't set Password for Postgres using docker-compose

I am not able to set Password for Postgres using Docker-compose. Postgres is loading without password and with the default user name "postgres", non of the envi

GroupingError: ERROR: column " " must appear in the GROUP BY clause or be used in an aggregate function

I am trying to create a list of unique patients who have left comments. The code words fine until I upload to heroku where it doesnt work in postgresql. This

How to Force Postgresql User Login with Password

All I did is in my local machine(Mac OS). After installing the postgresql, I created a user named poet with password, then created a database named poems and th

Docker Compose + Spring Boot + Postgres connection

I have a Java Spring Boot app which works with a Postgres database. I want to use Docker for both of them. I initially put just the Postgres in Docker, and I ha

Postgresql: How to repeat query as soon as finished?

Let's say I have a query like so: SELECT * FROM a WHERE a.Category = 'liquid' ORDER BY a.MeasurementTime DESC; and I want to see the results coming into the da

Detect SQL island over multiple parameters and conditions

(PostgreSQL 8.4) I got a great introduction to SQL gaps-and-islands here on Stack Overflow but I still have a question. Many island detection CTEs are based on