PostgreSQL is an enterprise class, open-source, object-relational database management system (ORDBMS) available for all major platforms including Linux, UNIX, Windows and OS X. Please mention your exact PostgreSQL version when asking questions.

learn more… | top users | synonyms (1)

1
vote
0answers
22 views

A costly approach to filtering on a calculated date

This builds off my previously wonderfully answered question Running a complex query for every date in a range I've got an expanded problem and I'm certainly not solving it in a performant way. The ...
6
votes
2answers
112 views

Running a complex query for every date in a range

I've got a table of orders Column | Type | Modifiers ...
2
votes
1answer
126 views

Should database be denormalized if I need an index across multiple tables

I have a catalog of album and song names. The song has a foreign key to the album table. I expect queries like: SELECT * FROM song s JOIN album a ON a.id = s.album_id WHERE LOWER(CONCAT_WS(' ', ...
2
votes
1answer
184 views

Postgres query plans and tuning parameters

I have a query for which the explain plan indicates that the cost for using a seq scan is lower than the cost for using an index that I have set up. However the actual time for the query is 20 times ...
0
votes
2answers
622 views

why pg_restore ignores --create ? Error: failed: FATAL: database “new_db” does not exist

I am trying to run following command: sshpass -p "pass" ssh x@1.2.3.4 "pg_dump -Fc -U foo some_db" | pg_restore --create --dbname=new_db I get: failed: FATAL: database "new_db" does not exist
2
votes
0answers
17 views

How to examine PostgreSQL server's SSL certificate?

Suppose there is a PostgreSQL server running and it has SSL enabled. Using "standard" Linux and PostgreSQL tools, how can I examine its SSL certificate? I'm hoping for output similar to what you ...
1
vote
1answer
118 views

Replication Lag on Postgres AWS RDS Service

We have a single master/single streaming replica Postgres 9.3 db on AWS. The load is not terribly high - this is a development/staging environment. (The production shows similar metrics). Point is the ...
7
votes
2answers
3k views

What is a valid use case for using TIMESTAMP WITHOUT TIME ZONE

There is a long and quite elucidating answer on the differences between TIMESTAMP WITH TIME ZONE -vs- TIMESTAMP WITHOUT TIME ZONE available in this SO post. What I would like to know is: are there ...
1
vote
1answer
113 views

How to create Postgres DB with case insensitive collation

I am using the postgres version 9.4.1 64-bit on windows 7 64-bit. I need to create DB with the setting "case sensitive = OFF" but couldn't make this work. I refereed already many question on SO and ...
1
vote
1answer
13 views

Use of smallserial gives error with PostgreSQL

I know the very basics of databases. I worked in the past with MySQL and recently switched to PostgreSQL (9.1) with PostGIS 2.0.1. At the moment I'm designing a new database and I use the tool ...
1
vote
0answers
21 views

Postgres - Error while adding constraints

Can anyone tell me what this error is? And How to resolve it? ERROR: could not read block 27651 in file "base/114689/118316": read only 4096 of 8192 bytes CONTEXT: SQL statement "SELECT ...
2
votes
2answers
198 views

Optimise huge Postgres table for fast read

I'm about to create a Postgres table with 1.5 billion rows. The table will just have a single TEXT column. The table is effectively a blacklist. When a user of my software saves certain data, this ...
3
votes
2answers
5k views

Tool for Reverse Engineering of PostgreSQL Database on Linux (Ubuntu) [on hold]

Please suggest a tool to reverse engineer a PostgreSQL DB into an entity-relationship-diagram (ERD) or equivalent ?? Ideally, I'm looking for a simple ERD or UML class diagram in a format that is ...
3
votes
2answers
135 views

CRUD operations on json data

I have a large chunk of json data associated with each id and I have to somehow get the data for my front end by querying through that large chunk. My TaskDetails table has a structure something ...
10
votes
1answer
6k views

postgresql: how do I dump and restore roles for a cluster?

Where are roles stored in a cluster, and how do I dump them? I did a pg_dump of a db and then loaded it into a different cluster, but I get a lot of these errors: psql:mydump.sql:3621: ERROR: role ...
3
votes
1answer
36 views

Why does this fast postgres query show up in the slow query log?

On investigating an entry in our Postgres log, I noticed a large discrepancy between the reported duration and the speed of the query. 2015-07-28 17:27:26 UTC [dms_segment_3] LOG: duration: 2924.763 ...
1
vote
0answers
124 views

Generally unsolvable problem? How to ORDER BY aggregated columns GROUPED BY many possible columns very fast?

Is there general solution or some best practises or at least some vague hint, how to solve following problem (general, but concretised in following example)? I think this must have been solved many ...
3
votes
1answer
30 views

Can jsonb do fast search by *value* or even a partial value? Other types?

I have a person table where arbitrary data must be inserted. Since I'm using Postgres 9.4, jsonb appears to be the right choice. Example data: id: 1, name: "Joe Doe", preferences: { color: "red" , ...
1
vote
1answer
20 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 ...
0
votes
2answers
116 views

Lower() vs ilike on postgresql

What I want to do is to check if value of column equals some string, but case insensitive. Is there a performance difference when using ilike without wildcards (percents) and lower() ? I was planning ...
5
votes
1answer
57 views

Bulk insert M:N relation in PostgreSQL

I need to import data from an old database to a new one, with slightly different structure. For example, in the old database, there is a table recording employees and their supervisors: CREATE TABLE ...
6
votes
5answers
19k views

Why won't PostgreSQL 9.3 start on Ubuntu?

I have successfully installed PostgreSQL 9.3 from the APT repository on 2 VM's running Ubuntu 12.04 and 13.04...however, I cannot get it to install properly on my host machine running Ubuntu 12.04. ...
12
votes
3answers
1k views

Can spatial index help a “range - order by - limit” query

Asking this question, specifically for Postgres, as it has good supoort for R-tree/spatial indexes. We have the following table with a tree structure (Nested Set model) of words and their ...
0
votes
0answers
17 views

Postgres 9.0 data huge folder

On our production environment we are using alfresco-4.0.c as content repository. Alfresco uses an instance of postgresql to index the contents. Looking at the filesystem size, I noticed I'm running ...
0
votes
1answer
15 views

SELinux is preventing pg_ctl from read access on the file postgresql.conf

I am trying to setup a master-slave PostgreSQL 9.4 database on Fedora 22, with the slave database's PGDATA being different from the default /var/lib/pgsql/data/ directory. I wrote this to ...
0
votes
1answer
117 views

Postgres Partition Table Trigger inserting duplicate records

I have a trigger applied on my database table. But when i insert data into it via hibernate jpa it creates duplicate rows in master table. Here is the trigger CREATE OR REPLACE FUNCTION ...
0
votes
0answers
22 views

How to populate values in drop down list in php postgresql [migrated]

I am getting error while populating the values in drop down list using php postgresql. Error means no output in drop down list. Below is my code. <!DOCTYPE html> <html> <body> ...
-1
votes
2answers
31 views

postgres9.4 streaming replication not streaming [on hold]

I configured a postgres pair for streaming replication, the pg_basebackup command was invoked successfuly on the slave, so I now have a copy of the master on it. The problem is that the slave does ...
1
vote
3answers
56 views

Intentionally corrupting an index in PostgreSQL

I need to know if there is any method for intentionally corrupting an index in PostgreSQL. I have been searching for it for a long time but never seen anyone mentioning such an act.
3
votes
1answer
190 views

PostgreSQL server problem in Windows XP

2014-10-01 09:22:49 IST LOG: database system was interrupted; last known up at 2014-09-30 18:30:24 IST 2014-10-01 09:22:49 IST FATAL: the database system is starting up 2014-10-01 09:22:49 IST LOG: ...
1
vote
1answer
41 views

How to optimize the sort in Postgres query

I've been trying to optimize the sort in the following query. I ran EXPLAIN ANALYZE and the majority of the time is during the sort when it arranges the output by distance. I've tried converting the ...
1
vote
1answer
16 views

How to determine if pg_dumpall is still running

Environment: Postgres 8.4 Debian Squeeze LTS Recently we switched from a backup solution around hot_backups to using pg_dumpall. This solution used a pid file as long as the hot_backup was ...
1
vote
1answer
23 views

How to have remote standby PostgreSQL server in different location (AWS)?

We have a primary PostgreSQL 9.4 server running multiple instances in our DC. It is using Continuous Archiving via WAL-E out to AWS S3. I would like to have a hot/warm standby server in our VPC within ...
1
vote
1answer
131 views

difference between pg_dump command's --column-insert and --attribute-insert

Background: I'm trying to create a dump file that only contains the data in my database. I would like it to create the data with the INSERT command. In reading the manual, ...
1
vote
2answers
37 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 ...
0
votes
1answer
20 views

Restore Postgresql data after hdd crash

My HDD crashed, so, I can't make a Postgresql backup. It seems that my data tables are OK (I can view the data via pgAdmin). However, when I run pg_dump I get this: pg_dump: Error message from ...
2
votes
1answer
37 views

Data synchronization across multiple databases

I have a Django application which uses PostgreSQL as a database. The application stores hierarchical data. It is like a warehouse management system with multiple branches and hierarchy. The current ...
2
votes
1answer
44 views

Row with latest timestamp

How to get the row with the latest value in a TIMESTAMPZ column? Is an index needed? Does an index change the strategy? Would behavior vary by database (I'm using Postgres 9.4)? My app records data ...
2
votes
1answer
2k views

PgPool 2 with HA Proxy

So, I'm looking to add high availability to a postgresql server. I've looked into some tutorials on the web but, haven't been able to find exactly what I'm looking for. E.g.: PostgreSQL ...
5
votes
1answer
51 views

Find rows where integer sequence contains a given subsequence

Problem Note: I refer to the mathematical sequences, not the sequences mechanism of PostgreSQL. I have a table representing sequences of integers. The definition are: CREATE TABLE sequences ( id ...
0
votes
0answers
27 views

insert value based on check constraint on another column [on hold]

I want to have domain_list field in db which will contain multiple domain values only if allowed_domain field is set to 1. I want to insert values in domain_list based on value of allowed_domain ...
0
votes
0answers
20 views

Postgres 9.1.16 Hot Standby

I am using postgres 9.1.16 (and i cannot upgrade :/) with Hot Standby. We have a few batch that perform some heavy writes, resulting in a lot of WAL produce in a short period of time. The standby ...
1
vote
1answer
656 views

Tree structure hierarchical query sorting

I have the following structure of table. CREATE TABLE table1 ( serial_num integer NOT NULL, parent_num integer, parent_key text, key_ary_num integer[], level integer, rank integer, ...
0
votes
1answer
108 views

Restoring a database using Postgres data files instead of .sql files

I backed up my Ubuntu 14.04 system using rsync to a USB stick, but apparently it wasn't formatted for booting. The original disk has been erased and I put a fresh install of Ubuntu on it. In migrating ...
0
votes
1answer
32 views

Best Admin Tool for Postgres [on hold]

can anyone tell me best the open source tool for postgres 9.4. Right now i am using pgadmin3. please suggest me if any other best tool is there for both developer level and admin level. Note : Tool ...
0
votes
0answers
18 views

DEFERRABLE INITIALLY DEFERRED in postgres after migration

I have used dbconvertool to migrate database from mysql to postgres. It is migrated successfully. But while comparing the table on mysql and postgres, i am seeing "DEFERRABLE INITIALLY DEFERRED" on ...
0
votes
0answers
3 views

PostGIS Intersects Query takes lot of time to get the result

I am developing a webmapping application in which I used PosgreSQL with PostGIS plugin as my DB. I have this two tables namely; evidensapp_polystructures and evidensapp_seniangcbr. Both tables ...
0
votes
2answers
3k views

Postgres FATAL: could not open relation mapping file

I installed postgress.app on mac os when I try to connect to console : psql -h localhost I got this problem . psql -h localhost psql: FATAL: could not open relation mapping file ...
1
vote
1answer
702 views

Configuring Postgres 9.2 streaming replication with Redhat Clustering Suite for High Availability

I'm in the process of configuring PostgreSQL 9.2 streaming replication with Redhat Clustering Suite for high availability. I have 1 master and 1 hot standby configured to replicate the data from ...
7
votes
3answers
168 views

Is it reasonable to mark all columns but one as primary key?

I have a table representing movies. The fields are: id (PK), title, genre, runtime, released_in, tags, origin, downloads. My database cannot be polluted by duplicated rows, so I want to enforce ...