All versions of PostgreSQL. Add a version-specific tag like postgresql-9.4 if that context is important.

learn more… | top users | synonyms (1)

1
vote
1answer
31 views

Plpgsql (Postgres) function for sanity check

While starting up my app, I need to do a sanity check within my database. In a table sensor, there's a column seconds. Now the function should take an argument id. It then should simply do something ...
1
vote
1answer
55 views

Data structure design for supporting arbitrary number of columns in table or database [closed]

I am currently working on a sort-of a meta-modeler to build a free web service so that people can input data and run several models on that data. The task I am currently struggling is: user needs to ...
1
vote
1answer
27 views

How to get particular object from jsonb array in PostgreSQL?

I have a field called 'user' that holds a json array that roughly looks like this: "user": [{ "_id" : "1", "count" : "4" }, { "_id" : "3", "count": "4"}] Now I want a query like: select count ...
1
vote
1answer
45 views

How to use SSL/TLS between server and client with Postgres?

I don't know much with it comes to security. I'm deploying a virtual machine with my database in a cloud service. I would like to encrypt all the communication between this server and any clients. How ...
1
vote
2answers
43 views

SELECT…FOR UPDATE - Will only an UPDATE release the lock?

I'm using a SELECT ...FOR UPDATE in a Java PreparedStatement. I may or may not need to execute the update depending on the results of the SELECT. If I execute a rs.close(); or pStmt.close(); without ...
1
vote
2answers
43 views

What is table bloating in databases

Can someone explain what bloating means in database terms. For example what does it mean to say an index is bloated. I tried searching for it but there is no explanation of what bloating is . Only ...
1
vote
2answers
40 views

How to set roles and users with correct permissions on Postgres? [closed]

My current database uat has as owner postgres. But now I would like to set roles and users with the correct permissions. Something simple like: roles: dba, developer, application users: dba1, dev1, ...
1
vote
1answer
50 views

PostgreSql : flatten json array data

From my current query, I obtain this jsonb data : values: "a1", ["b1", "b2"] And I want to flatten it on one level only, like this : values: "a1", "b1", "b2" Here is a simplfied way to get ...
1
vote
1answer
31 views

PostgreSQL: Restoring 1 file from a directory format dump

I've got a large'ish (> 700GB) PostgreSQL database. I'm working on importing it into AWS RDS. I realize there are modules that will cause problems, we're dealing with that separately, so for right ...
1
vote
1answer
38 views

How do you configure Postgres 9.4 for incremental backups and hot standby?

I want to set up Postgres to do incremental backups. I'm using PostgreSQL 9.4 on Windows with a database that weighs about 1GB and has a growing 10000 records each day. I understood that the steps ...
1
vote
1answer
25 views

How to automatically drop and restore PostgreSQL database

I am using dhis2 with PostgreSQL as database but I want to verify my backups from the cloud by restoring and checking whether the data are ok but I need it to be automatic.
1
vote
2answers
25 views

Recreate all foreign keys in all tables as deferrable (batch)

I want to make all foreign keys in my database deferrable. But there is no possibility to alter an existing constraint. So I need to drop and add again each foreign key. How to do it automatically?
1
vote
1answer
131 views

Slow query - Optimize - PostgreSQL

I've got a slow query here... could you please help me to optimize it? Query: SELECT concat(company, ' ', customer_name_first, ' ', customer_name_last) AS customer, sum(revenue) AS revenue, ...
1
vote
1answer
44 views

Does ALTER on PostgreSQL, Oracle table (respectively) create intermediate copy of the table?

I've heard MySQL admin claim that ALTER on MySQL table creates an intermediate copy of the table during the operation (don't know if the type of table involved were supposed to be MyISAM or InnoDB), ...
1
vote
1answer
223 views

Upgrade PostgreSQL 9.4 to 9.5 : LC_ALL unset

I'm trying to upgrade my PostgreSQL 9.4 database to PostgreSQL 9.5 but everytime while running sudo pg_upgradecluster 9.4 main I get this error: Stopping old cluster... Disabling connections to the ...
1
vote
1answer
33 views

Strange upper() behaviour for dateranges in PostgreSQL

I'm running PostgreSQL 9.4.5 and I've just got an unexpected result from this query: select upper(('[2005-12-01,2005-12-04]')::daterange) It returns 2005-12-05 instead of 2005-12-04. The ...
1
vote
1answer
77 views

How to drop all of my functions in postgres in single step

Right now I have to use query to get the command in text file. Then remove double quote from them. And finally, run that file in psql shell. Here is my steps. 1. Use these ...
1
vote
1answer
65 views

Is it possible to obtain number of prepared statements a connection holds?

I have a heavy loaded application that holds connections persistently (it creates them on start and never releases). During the lifetime it creates and (re)uses prepared statements, which are stored ...
1
vote
1answer
28 views

Adding new user in Postgres

I am using AWS RDS PostgreSQL and currently up and running. I would like to know how I can add a new user but only grant SELECT on an existing DB. The way I connect to my RDS from my PC is by using a ...
1
vote
1answer
54 views

Discover missing foreign keys and/or indexes

We have a pretty big database (around 700GB of data), which has been inherited to us, and has had several DBAs. With time we've realized that there are several missing foreign keys and indexes. I'd ...
1
vote
1answer
36 views

Get triggers/table names in PostgreSQL

How can I get a listing of all triggers for a database along w/ the table that it belongs to? I assume that I need pg_trigger and pg_tables but I'm not quite sure how to join them together.
1
vote
1answer
48 views

How can I select records which are between 2 dates based on a date in a field in PostgresSQL?

I have two tables: 1 with an Unique ID with the first time they visited (in date format) and a historical addresses table with the same Unique ID, a start field (date field), an end field (date ...
1
vote
1answer
55 views

Find unmatched rows between two tables dynamically

I have a function here that is supposed to take two tables as arguments and check if they are the same. create or replace function testing.equal_tables( varchar, varchar) returns void as ...
1
vote
1answer
46 views

Postgres corrupted index on update

Sometimes, when doing an update on a specific table record, i get this error: index "myIndexName" contains corrupted page at block 468 Please REINDEX it. But on the next update it works, without ...
1
vote
1answer
107 views

return subquery value into main query

I have the following query: SELECT * FROM item_ledger WHERE to_id='7' AND (SELECT SUM(qty) AS qty_in FROM item_ledger WHERE from_item_ledger_id='5') < intransit_qty the query ...
1
vote
1answer
48 views

Can sequential queries result in concurrent transactions?

I'm using PostgreSQL 9.4.4 and the default configuration. I use a JDBC connection to run multiple queries in succession. Only one Java thread is using the connection and before a new query is executed ...
1
vote
1answer
55 views

Where can I see the exact row count of a table in pgAdmin III?

Where can I see the exact row count of a table in pgAdmin III? I know where to find the approximate row count: I am also aware I can SELECT COUNT(*) FROM my_table. But I want to know whether the ...
1
vote
1answer
55 views

Low cardinality fields: integer or string

A Ticket has the statuses: new in_progress on_hold closed I could make ticket.status a string (on_hold) or an unique int(2). It is indexed. Int pros: smallest size in index Int con: low clarity ...
1
vote
1answer
41 views

how to obtain a list of restore points?

i am implementing restore points using pg_create_restore_point, and will then have a set of scripts to enable my users to restore to one of these restore points. Clearly i have work to do with taking ...
1
vote
1answer
64 views

Is my postgres index being used?

I have a large PostgeSQL 9.1 database in production use. I want to free up some disk space. There is a large index, and I'm unsure if it's being used. select * from pg_stat_all_indexes where ...
1
vote
1answer
38 views

Aggregate rows of type array

I need to aggregate rows with a single column of type INT[] into a single array of type INT[]. The following results in an error "could not find array type for data type integer[]": create temp ...
1
vote
1answer
55 views

PostgreSQL Streaming Replication - corruption on master

We have PostgreSQL 9.3.9 streaming replication between Master DB and Slave DB. Is there issues can happen on Master that can cause persistency problems or full failure of Master and Slave DB both ...
1
vote
1answer
105 views

Promoting warm standby to master with Postgresql 9.4 using streaming replication

I've currently got 2 database servers running Centos 6 and Postgresql 9.4 (identical clones on the same network). They are set up as a primary and a backup created using pg_basebackup from the ...
1
vote
1answer
35 views

IOPS needs of Root Volume vs Database/Log Files Volume

I'm setting up a database server via AWS EC2, using: Root EBS Volume, General-purpose SSD EBS Volume, Provisioned IOPS And intending to configure PostgreSQL to have the database and log files on ...
1
vote
1answer
215 views

Count how many child a parent has in a recursive cte

This is the query I'm using to find comments by a parent id WITH RECURSIVE cte (id, content, path, parent_id, depth) AS ( SELECT id, content, array[id] AS path, ...
1
vote
1answer
38 views

Advantages of POINT over DOUBLE for distance queries?

I'm about to start an application that will need a simple distance query to order results. After some search I've discovered some functions that seems to do this work pretty easily without needing ...
1
vote
3answers
78 views

Create database design with requirement

I has a small database structure with an Account and Person. I want apply the following requirement: Account have one Person Person do not have necessarily one Account (can be null) When I delete ...
1
vote
1answer
77 views

How to use a value from insert in conditional insert in postgres

insert into addresses(street, city, user_id) select 'street1','LA', 2 where exists (select * from users where users.id = $$$$$ AND users.storeaddress='true')) I want to insert address for a ...
1
vote
1answer
32 views

Looks like a postgres backup/dump structure (A sort of a forensic/data archeology question)

I was given a compressed folder that contains number of subdirectories, and, among others, directories named .pgdir with number of numerically sequenced files in a <9999>.dat.gz format and one in a ...
1
vote
1answer
50 views

Passing array from one plpgsql function to another

I have a function in PostgreSQL 9.4 that calls another function. Both are written in plpgsql. The child function takes an array argument representing IDs from a table that is used to create a new ...
1
vote
1answer
42 views

Calculate column running total

Given the following schema and dummy data: CREATE TABLE transactions ( id SERIAL PRIMARY KEY, memo VARCHAR(255) NOT NULL, amount INT NOT NULL, tx_date DATE NOT NULL ); INSERT INTO ...
1
vote
1answer
18 views

Are toast columns compressed also in shared_buffers?

Reading here I cannot find a clear answer: http://www.postgresql.org/docs/9.1/static/storage-toast.html I need to know if setting storage to EXTERNAL for a particular column, I can gain a little ...
1
vote
1answer
95 views

Batch for PostgreSQL query

1) The pgpass.conf (of PostgreSQL) is: localhost:5432:*:postgres:mypassword I have no experience with batch and I have spent the day searching in the net. I'm using Windows - if that matters. 2) ...
1
vote
1answer
433 views

Debugging Postgres error: “could not send data to client: Broken pipe”

I'm running a Django 1.8 site, served by nginx and Gunicorn, with a Postgres 9.4 backend. When I make lots of data-intensive calls to the site's API in succession, I've noticed about 1 in 100 ...
1
vote
1answer
87 views

PostgreSQL bug(?) - logging with a minimum log level

I am using the log_min_error_statement - Setting in the PostgreSQL configuration file, but the logger does not react on the setting, either if I turn it on, or off, or set it to another level, the ...
1
vote
1answer
25 views

Safe to Restore Database from Untrusted Sources

I am asking someone to aggregate around 100GB of data for me. I would prefer this to be in a Postgres database instead of something like CSV. I was thinking pg_dump and pg_restore custom format. Is it ...
1
vote
1answer
231 views

Columns names are case sensitive on postgres

I have successfully migrated database from MySQL to PostgreSQL. While I am trying to connect with ofbiz, I am getting an error saying that "user_id" not found. When I query against postgres by ...
1
vote
1answer
297 views

Create postgres schema in db with multi user in AUTHORIZATION

Is it possible to create a schema that is owned or accessible by more than one user in the same database? I was reading postgres create schema documentation and postgres alter schema documentation ...
1
vote
1answer
63 views

Storing Large Nested Objects

What is the best way to store a large (thousands of properties) nested JSON object in Postgres? It does not need to be index, queried, or anything. Just written and read. Write speed isn't an issue ...
1
vote
2answers
152 views

Access to database denied :ELEPHANTSQL on Bluemix - “No pg_hba.conf entry for host localhost, user ADMIN, database SYSTEM”

While trying to connect to my ElephantSQL database on Bluemix using pgadmin, it throws the following error. Access to database denied The server doesn't grant access to the database: the server ...