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)

0
votes
0answers
15 views

Turn off serialization failure logging

Is it possible to turn off serialization failure logging? If so, how? For example, my log is filled with this example: ERROR: could not serialize access due to read/write dependencies among ...
0
votes
0answers
19 views

index of aggregate value with fast update?

Is it possible for me to index the sum of a particular table column, such that future lookups will not have to scan the entire table? This table will grow to be very large and a sum of the entire ...
1
vote
2answers
71 views

Is unique index better than unique constraint when an index with an operator class is required

Postgres docs say: The use of indexes to enforce unique constraints could be considered an implementation detail that should not be accessed directly. One should, however, be aware that there's ...
0
votes
0answers
19 views

pg_dump in 1G VPS crashes

I'm trying to run pg_dump on a relatively small database (2G), but pg_dump keeps crashing with an out of memory error. du -h --max-depth=0 9.4 1.9G 9.4 The command: pg_dump -Fp -h "$HOSTNAME" ...
0
votes
2answers
47 views

Product Attribute System While Avoiding EAV

I'm working on building an attribute system for products. The issue that I'm running into is that various products can have very different attribute requirements. Some E-commerce websites such as ...
0
votes
1answer
22 views

Postgres - Inject 0 values when rows do not exist

I have 3 tables that I need for reporting: *dates* date_sk | full_date | day_number_of_month 1 | 2013-01-01 | 1 2 | 2013-02-01 | 1 3 | ...
1
vote
1answer
27 views

Count of 3 consecutive unsynced dates

I have a table set out like so: user_id the_date minutes_asleep ---------------------------- 1 2015-01-01 480 1 2015-01-02 0 1 2015-01-03 0 1 2015-01-04 0 ...
1
vote
1answer
41 views

PostgreSQL Primary key disappears from test table

I have a somewhat convoluted scenario where a test table I had created with a primary key won't return the primary key. pgAdmin III reports there are no constraints. I have the entire PostgreSQL query ...
1
vote
0answers
39 views

How to optimize inefficient query in PostGIS

I'm doing some queries on a PostGIS, and some of them take a really long time ( > 60 secs). My queries are like this, except querying different tables (like osm_placesbelow). This query takes about ...
0
votes
0answers
22 views

Extract timestamp from UUIDv1

Is it possible to extract timestamp from uuid version 1 in PostgreSQL? I am also curious is it possible to order by uuid's timestamp value like it's done in Cassandra's TimeUUID datatype?
0
votes
0answers
18 views

pg_restore certain tables only

I'm looking for a way to use pg_restore to restore a newly-created database from a dump file, but only certain tables from that file. (There are a lot of extra tables in the database that are slow to ...
1
vote
1answer
73 views

Non-sequential Primary Key performance in PostgreSQL 9.3

Due to requirement to support distributed environment, each of my clients has been assigned unique node id, it appends the node id with running number as primary key and stores at local database. E.g. ...
1
vote
1answer
111 views

PostgreSQL SELECT primary key as “serial” or “bigserial”

I've meshed together a way to determine what the data_type is as in the data_type you use in the syntax when creating a new table based off of the PostgreSQL wiki page. If there is something wrong ...
1
vote
1answer
24 views

Alternate per 2 postgresql rows, but start over if there are rows remaining

I'm trying to select below table, grouped by two (=max, if there is only one, show one) of each supplier_id. But, after all suppliers are selected it needs to start over. So this is the table: Table: ...
1
vote
1answer
76 views

Export Postgres table as json

Is there a way to export postgres table data as json to a file? I need the output to be line by line, like: {'id':1,'name':'David'} {'id':2,'name':'James'} ... EDIT: postgres version: 9.3.4
1
vote
2answers
86 views

How to do an =ANY(SELECT…query in postgresql?

I'm trying to select all the latitudes and longitudes for a group of users based on their id being in an array stored in another table. Here's my attempt: SELECT latitude, longitude FROM userloc ...
2
votes
1answer
33 views

How to enforce an “exactly-one-per-group” constraint?

I have a table x that I've defined like this: CREATE TABLE x ( xid INTEGER NOT NULL PRIMARY KEY, yid INTEGER NOT NULL REFERENCES y(yid), is_principal BOOLEAN NOT NULL ); This definition ...
1
vote
0answers
39 views

Is it bad practice to launch more than 100 sql statements at once?

I have PHP code that is meant to updating the billing status of someone. I only want it to update if the bill has been successfully created and therefore I think a possible solution would be to ...
0
votes
2answers
72 views

Is making joins between different table spaces slower?

In MySQL and PostgreSQL, is making joins between different tablespaces inherently slower, compared to joining tables in the same tablespace?
1
vote
1answer
34 views

Rely on .pgpass in CREATE USER MAPPING

I am trying to create a script which creates a postgres-fdw connection between two postgres 9.4 databases. The script (which is checked in under version control), has been relying on pgpass to do ...
0
votes
1answer
42 views

Amazon RDS non superuser create function in C

I am asked to restore a Rails application to a postgresql RDS instance. There are many functions in C but looks like only superuser can create functions in C and I could not get superuser access on ...
1
vote
1answer
47 views

How to view full blocking postgres queries?

I'm using a statement from this page to view blocking queries in Postgres SELECT bl.pid AS blocked_pid, a.usename AS blocked_user, ka.query ...
1
vote
1answer
16 views

Determine existence in recursive working table

I have a query that needs to check for existence of each input row type in another table, but it is unnecessary and inefficient to check for existence of subsequent rows of the same row type if one is ...
1
vote
0answers
24 views

XRC error when trying to access PostgreSQL view properties

I have strange problem, when trying to access PostgreSQL view properties through PgAdmin III: Error: XRC error: 197: invalid row index 1: must be less than 1 After this error is displayed, I am ...
0
votes
0answers
11 views

postgres containers share pgdata mount

Due to an oversight, we have 3 postgres containers (docker) all mounting the same pgdata directory. In essence this means 3 postgres instances are running over the same pgdata. I imagine this would ...
0
votes
1answer
98 views

pg_restore: [archiver (db)] could not execute query: ERROR: schema “public” already exists

I am using pg_dump / pg_restore to backup and restore a PostgreSQL database, but am getting some error messages (and a non-zero exit status) from pg_restore. I tried a super simple base case (outlined ...
0
votes
0answers
3 views

Delete fabricante_producto_solicitud only if is not related to modelo_marca_producto

I have this related tables: It's possible, in one query, check if fabricante_producto_solicitud has relation with modelo_marca_producto or do I need to rely on programmatic way? I need some ...
0
votes
1answer
64 views

Compare data between 2 different schemas

We refactored our old database. Some tables were dropped, some tables were split into 2 new tables etc. So now we have an absolutely new DB schema which has many differences from the old one. Someone ...
2
votes
2answers
67 views

Is there a way I can speed up queries against this particular view?

I have three tables in a PostgreSQL database that I'm querying via a view and some joins. CREATE TABLE network_info ( network CIDR NOT NULL, some_info TEXT NULL, ...
0
votes
1answer
22 views

PostgreSQL determine column type when data_type is set to ARRAY

I came across an oddity where PostgreSQL sets the data_type to ARRAY in the information_schema.columns table. I did the following query to gain some insight: SELECT * FROM information_schema.columns ...
0
votes
2answers
51 views

Keep trailing zeros on Timestamp SELECT

This is the issue: I am reading rows with a timestamp column from a table and I need to make sure that the database returns the timestamp with a fixed width. But I am encountering instances where the ...
0
votes
2answers
30 views

join value in a RETURNING which is not inserted

Im doing an insert from a query which joins two tables, then I want the new ID from the inserted row, and a field from the original row which is not involved in the insert.Is it possible? I get a ...
3
votes
1answer
45 views

(How) does table inheritance interfere with locking in postgres?

I have a table inheritance setup that might be simplified like this: CREATE TABLE p ( id BIGSERIAL PRIMARY KEY, type_id BIGINT, approved BOOLEAN ); CREATE INDEX ON p(approved); CREATE ...
0
votes
0answers
19 views

Need help on transferring data from a PostgreSQL database to a future (to be decided) database!

(English isn't my native language) I'm doing an internship for school and my task is to theoretically describe the best way to transfer the data from their current database (PostgreSQL) that they have ...
0
votes
1answer
19 views

Adding column to Postgres table fails

I have a Postgres (8.4.20) table that I'm supposed to add columns to, but it seems to have some problems that I have difficulties to debug: I'm attempting what I thought was a simple ALTER TABLE... ...
0
votes
0answers
50 views

Postgres 9.0 recovery from inadvertent drop-all-tables event

Due to a accidental config file check-in, a unit test wiped out our entire production database (did a drop, then re-created the tables). Trying to restore from backup revealed the recent backups were ...
2
votes
1answer
80 views

Unused index in range of dates query

I have a query that is not using existing indices and I do not understand why. The table: mustang=# \d+ bss.amplifier_saturation Table ...
0
votes
1answer
35 views

Storing latitude and longitude

I know there are similar questions on here that have been answered but unfortunately none of them work for me. I am hacking my way through creating a page which will display multiple locations on a ...
4
votes
2answers
75 views

Take advantage of monotonic columns in PostreSQL

I have a PostgreSQL table with, among the other, two columns named col1 and col2, both of integer type (there are around 10M rows in the table). I want to perform SQL queries like: SELECT * FROM ...
0
votes
0answers
44 views

PostgreSQL Performance - Many Large Databases

I run an internal (development) database server containing 25 databases each ~71GB in size. There are usually between 50 and 100 active connections at any given time. What can I do to help improve ...
0
votes
0answers
34 views

Replication Strategy for Multi-Office Database

I'm considering options for setting up a repository of large spatial datasets that can be used by employees across our company. We have offices scattered around the US. Our employees utilize ...
1
vote
0answers
27 views

choosing between the slaves on streaming replication

We are building a new streaming replication setup on postgres 9.3 integrated with pgpool for load balancing and failover, and repmgr for replication business. We have seperate daemons running on all ...
4
votes
1answer
94 views

PostgreSQL operator uses index but underlying function does not

I'm attempting to use JSONB with JDBC, which means that I have to avoid any of the operators which use the '?' character (as the PostgreSQL JDBC driver has no escaping for this character). Taking a ...
3
votes
1answer
84 views

PostgreSql JSONB SELECT against multiple values

I have a very simple JSON table which I populate with some sample data: CREATE TABLE jsonthings(d JSONB NOT NULL); INSERT INTO jsonthings VALUES ('{"name":"First","tags":["foo"]}'); INSERT INTO ...
1
vote
1answer
45 views

PostgreSQL: Foreign key on string column

I'm currently in a process of redesigning a legacy database. One of the tables primary key is a varchar(254). I need to create a table relating to it. So for example: create table "Item" ( ...
1
vote
0answers
17 views

Simplifying UNION query that looks for duplicate names

create table sections( id serial, section_name char(255) not null, version_id int not null ); create table section_versions( id int primary key not null, version_name char(255) not null ); ...
0
votes
1answer
42 views

How to store thousands of properties related to a record in PostgreSQL?

I have a database of approximately 300K records. For each of theses records there are up to 1600 related properties. Each of these properties have a simple key=>value format. This data is very static ...
0
votes
2answers
40 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 ...
0
votes
3answers
88 views

Getting around the constraint “column must appear in the GROUP BY clause or be used in an aggregate function”

I'm using Postgres, which enforces the constraint that all columns in a SELECT...GROUP BY must appear in the GROUP BY clause or be used in an aggregate function. Lets say I'm modelling peoples' cars, ...
0
votes
1answer
28 views

NOT IN statement or what to use in this case?

I need to delete each row in fabricante_producto_solicitud (fps from now on) table if fps.id has not relation (NOT IN) fabricante_modelo_marca_producto (fmmp from now on). Since my input will be an ...