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
2 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
1answer
40 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
0answers
12 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
0answers
10 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
17 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 ...
0
votes
1answer
9 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 ...
0
votes
0answers
5 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
5 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
19 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
26 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
45 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
18 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
1answer
28 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 ...
-1
votes
1answer
31 views

How to select a record and update another record with selected

Say, I have a table: User User_key User_id User_name User_status State 1 001 Adam Active CA 2 002 Zack Active NY 3 003 ...
0
votes
2answers
28 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
29 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
17 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
16 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
39 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
47 views

Unused index in range of dates query (PostgreSQL, timestamp with time zone)

I think maybe I am making a dumb mistake here, so apologies in advance. But I have a query that is not using existing indices and I do not understand why. Am I reading the plan wrong? Are the indices ...
0
votes
1answer
22 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
60 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
32 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
22 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
20 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
0answers
52 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
45 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
33 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
13 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
30 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 ...
-4
votes
0answers
30 views

Getting count on multiple fields from table [closed]

Please take a look at this page Travelmob. As you keep filtering on the "Amenities" or "Experience" on the left side, it update the total count on all of the fields. How do they do that? (could it ...
0
votes
2answers
29 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
56 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
27 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 ...
1
vote
0answers
29 views

Maximum sum() of overlapping ranges

Essentially my question is: how does one do aggregate operations involving overlaping ranges in Postgresql 9.3 (or 9.4)? The specific problem I have at hand is that given a range, I want to find the ...
0
votes
0answers
52 views

Problem installing postgres 9.4 on Windows R2

I am trying to install postgres 9.4 on Windows using the "Enterprise db" installer and in the last part of the installation show the message "Failed to initialise the database cluster With initdb". I ...
0
votes
0answers
20 views

PostgreSQL and array of custom type

One of the table I have looks like this CREATE TABLE orders_suppliers_contacts ( supplier_id bigint NOT NULL, name character varying(64) NOT NULL, phone character varying(18), notes character ...
0
votes
1answer
38 views

Safe way to perform DB upgrade

If I am reading the documentation correctly, issuing this command psql -v ON_ERROR_STOP=1 database < script.sql where script.sql starts with BEGIN BEGIN; ALTER TABLE... some other DDL... ...
1
vote
2answers
45 views

Efficient query to get last row group by multiple columns

I have a table like the following: spread_id serial NOT NULL, game_id integer NOT NULL, sportsbook_id integer NOT NULL, spread_type integer NOT NULL, spread_duration integer NOT NULL, home_line ...
-3
votes
0answers
14 views

compact database [closed]

I am using postgres 8.4 for Jboss Operation Network on Centos, now I want to compact the data ! can you give me best idea about that compact the data and also share with me step be step procedure ...
1
vote
1answer
38 views

Use result of aggregate in same select?

Is it possible to feed the result of an aggregate select into the same select with Postgresql? I'm aware of the WITH clause -- but, this would be true syntactical sugar, wouldn't it? SELECT ...
1
vote
2answers
44 views

Slow query when adding additional where clause

Here's my setup (Postgres 9.3) Posts project_id Messages post_id kind updated_at I'm trying to get the most recently updated 100 messages that belong to posts (on a specific project) that are ...
1
vote
1answer
42 views

Why won't pg_basebackup output go to log?

I run a nightly pg_basebackup from a cron job (Postgres 9.3 on debian "wheezy"), but the backup has been failing. It actually creates output, but the .tar file is corrupt and won't extract. I went to ...
-2
votes
1answer
38 views

Timeline or time function in PostgreSQL

In MySQL I can use this select which show timeline view on data in my table/tables. SELECT COUNT(atribute), connection_timestamp FROM db GROUP BY DAYOFYEAR(connection_timestamp) ORDER BY ...
0
votes
2answers
36 views

PostgreSQL: Use column with hash based on other columns as unique index?

My previous problem is still not fixed: We cannot set a unique index because NULL values are allowed... we use this table in our database: CREATE TABLE offer ( offer_id serial PRIMARY KEY , ...
0
votes
0answers
38 views

Is there any free, usable PostgreSQL formatter on Windows? [closed]

We're using pgAdmin3 and Notepad++ and we need some kind of a formatter that helps us format the old code we took from the lazy programmers. What I tried so far and didn't work: Poor Man's TSQL ...
0
votes
1answer
26 views

how to query multiple counts on related tables

For each Forum, there are many Posts, and for each Post, there are many Comments I'm trying to query the total number of Posts and Comments for each Forum So I'm looking to have an output as such: ...
1
vote
1answer
31 views

Is there a way to query all error messages in Postgres?

Postgres has a catalogue of possible error messages here: http://www.postgresql.org/docs/8.2/static/errcodes-appendix.html#ERRCODES-TABLE However, I would like to query this information from a ...
1
vote
2answers
44 views

Return the id after insert or select

I want to build a function which will insert an email if the email value doesn't exist in the table and return the email_id of the row. How can I do this? Also how can I return the id if the email was ...