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)

3
votes
0answers
8 views

Migration From Oracle to PostgreSQL Encoding Errors

I'm working on migrating data from an oracle database to a postgresql database. I running into a problem where I export the data from oracle, using sql developer, and importing it into postgresql. ...
1
vote
1answer
10 views

Creating a database under a different owner

I'm trying to set up a role in Postgres which can a) Create a new Role b) Create a new Database c) Make that new Role the owner of the database d) Have no other rights (as far as is possible!) I have ...
2
votes
0answers
35 views

Unique Index much bigger than the table itself

Pg 9.3 on debian 7. I have a very huge table in rows, about 178 million (will turn 250 million in a week and then grow 500 thousand a day), but not that huge in size, wich is 20GB, it's a small ...
1
vote
0answers
22 views

Is there a way to improve this query further?

I've got a query that over time I've been improving. Originally it simply selected * from the records table, and the data was formatted on the webapp side. But that was slow and I wanted to make ...
-1
votes
0answers
10 views

How to Insert geom line in geom geometry column?

I am a beginners and I have the coordinates of a lot of points in a table. In pgadmin I want to make a line that passes on these points. I already have my Coordinate point im my table. I want to make ...
0
votes
0answers
16 views

DB space vs query complexity tradeoff

I have a dilemma - Right now I have a query that I do constantly - joining 5 tables on different columns, calculate stuff per row, distinct on that, and do that with offset and limit (pagination). I ...
0
votes
0answers
10 views

Recovering from a partial recover/migration

I migrated my database with a simple pg_dump -p <port> -U <user> <database> | psql -p <other port> -U <user> <other database> and was kindly interrupted by a ...
2
votes
1answer
27 views

How to keep updates (diffs) of some entity in the database

What is the best way to keep updates (diffs) of the some entity in the database? At StackOverflow we can edit questions and answers. And then we can look at any revision of the question or answer we ...
1
vote
1answer
21 views

Postgres - Insert performance with indexes

We have a table with about 20 columns in a Postgres 9.2.10 DB. For better performance on some SELECT queries, we plan to add an index on one column with data type timestamp. As the index also can slow ...
0
votes
0answers
32 views

migrating from Postgres to MonetDB [on hold]

I have postgres database (24 schemas, about 50 tables for each schema, partitioned tables) and I want to migrate to MonetDB database, but I dont know best way to do this. How can I restore data? I ...
0
votes
1answer
16 views

Trigger function check if all NEW.* fields exist in another table

In PostgreSQL I need to code a trigger function that checks if all the fields in NEW.* exist in another table that has the exact same name as the table that fired the trigger but appended with "_hv". ...
0
votes
0answers
9 views

How to sync postgres roles between multiple servers

I am looking for a solution in which I can replicate the details of a role (most notably the password) between various postgres servers. (All running the same version). The idea behind this is that ...
0
votes
0answers
25 views

Use a function(select or insert) in a streaming rep with hot standby setup [on hold]

Setup Pgpool Master Slave mode On / stream Load Balance Mode On Health Check On And two nodes(primary and standby) I have this function (the function is in the question), how can I use it in ...
0
votes
0answers
5 views

Making ordinal synonyms for Postgres full text search

I have a Postgres 9.3 database where users are mostly searching for locations by a combination of name and/or address (or fragments of). An example of an address would be "123 8th st". I've been ...
0
votes
1answer
22 views

Postgres - count of GROUP BY

I am trying to determine the total number of contributors in an image database who have contributed at least five images. The following query will give me counts of images by contributor, but that's ...
0
votes
0answers
15 views

Is there a workaround for the lack of foreign keys constraint to a partitioned table in PostgreSQL?

I have a big table A (~30 million lines) at the core of my model. Another table B has a foreign key referencing A. I would like to partition A using the well-known inheritance hack. Is there a ...
1
vote
1answer
26 views

Return type of JOINing stored procedure - PostgreSQL

Is it possible to express return type of stored procedure that returns joined tables using table type of one of joined tables? My stored procedure looks like this: CREATE or REPLACE FUNCTION ...
2
votes
1answer
22 views

Select into specific position with array_agg on postgresql

Is there a way to set value in specific position inside array based on information from other columns (PostgreSQL-9.3 and later)? For example I would like to select an item and its stock information ...
1
vote
0answers
24 views

Restricting user to a single db in postgresql [duplicate]

I've a PostgreSQL Server with 5 db and 2 users: postgres and forge, both with Superuser attribute. I want to create a third user that can only see and use one and just one of the db and by using it I ...
0
votes
0answers
25 views

PostgreSQL trigger copy record to another table with different columns order

I have a trigger that before every update on hundreds of tables it inserts into a table with the same name and the _hv suffix a copy of the record being updated to maintain a kind of historical ...
-2
votes
0answers
17 views

I want query postgresql group by month and type [on hold]

I want query postgresql group by month and type like this, please help me.
0
votes
0answers
12 views

how to install a database cluster in postgresql

I am trying to install POSTGRESQL, I have completed the installation and at the end point i got an error stating POSTGRESQL CLUSTER INITIALIZATION is not succeed and this if i install outside the ...
1
vote
1answer
109 views

How to return values from “upsert” query in case when UPDATE has been performed?

WITH upsert AS (UPDATE tbl SET a = 2 WHERE a = 1 RETURNING tbl.*) INSERT INTO tbl (a) SELECT 1 WHERE NOT EXISTS( SELECT * FROM upsert ) RETURNING * This "upsert" statement works however I would like ...
0
votes
1answer
35 views

Maximum Partitioning PostgreSQL

I have 400,000 records I need to partition. The records will increase 100,000 per year and those new records might need to have 1000 new partitions added. Here are some of my concerns: How many ...
2
votes
1answer
25 views

Search for authors whose records are separated by at least X days

I am using Postgres and have a table which contains metadata about several million images - many of which have the same author. I am looking for contributors who add content regularly - not people ...
2
votes
1answer
49 views

Why do we need partitions in PostgresSQL? (or any other RDBMS)

So, I am trying to teach myself partitions in PostgreSQL. I understand that a database can become slow when a table hits millions+ of lines and indexes don't fit into memory anymore. One thing that ...
0
votes
0answers
26 views

List all columns and rows of PostgreSQL table with a view limit

I am currently using select * from items; to show my table during development however I am finding it a bit messy now as some the strings I am adding to the table are 1,000+ chars long. Is there a ...
0
votes
1answer
22 views

Postgres tablespace on mounted usb

I've got postgres 9.1 running on raspbian installed with apt-get. I've got NTFS usb HDD mounted in /mnt/usb. What I'd like to achieve is to create a tablespace pointing to /mnt/usb/postgres so I ...
0
votes
1answer
27 views

PostgreSQL Error Codes [on hold]

I'm configuring a monitoring tool to monitor a PostgreSQL 9.3 database error log and notify me whenever there are errors. Now I'm in the phase of understanding the difference between error codes. For ...
2
votes
1answer
45 views

Problems restoring backup from base backup + WAL with WAL-E

I'm trying to do nightly restores of the main database on a separate node. I want to do weekly full restores and nightly restores by consuming the latest WAL files. On the master I have wal_level = ...
0
votes
1answer
23 views

Display only table names in psql

How can I print only table names from a specified database in psql? That is, if I have tables called "table1" and "table2" then the output will be: table1 table2 and only that. I've been trying ...
2
votes
1answer
29 views

Guid vs. integer ID for unique fields

This is really a generic question. Suppose I have a replication pattern of a single write DB and multiple read DB replication slaves - I do not have to have GUID's as my unique IDs fields. Is that a ...
1
vote
0answers
24 views

Trouble renaming a PostgreSQL database [duplicate]

Trying to rename a postgres database: $ psql -d some_other_database some_other_database=# ALTER DATABASE myapp_development RENAME TO myapp_development_old some_other_database-# \l ...
2
votes
1answer
59 views

Updating table of versioned rows with historical records in PostgreSQL

I have a master table of versioned rows: CREATE TABLE master ( id SERIAL PRIMARY KEY, rec_id integer, val text, valid_on date[], valid_during daterange ); INSERT INTO master ...
1
vote
1answer
18 views

Stop PostgreSQL from logging statements on error

My postgresql 9.3 logs are sprinkled with entries like these (redacted to protect the guilty): STATEMENT: INSERT INTO table (key, value) VALUES ($1, $2) ERROR: duplicate key value violates unique ...
2
votes
1answer
27 views

Does Postgres preserve insertion order of records?

For example when I'm using query which returns record ids INSERT INTO projects(name) VALUES (name1), (name2), (name3) returning id; Which produce output: 1 2 3 Will this ids point to ...
2
votes
2answers
42 views

Unique across tables

I have a table containing users. Each user has a primary email and a flag indicating if the user is deleted or not (we never hard-delete users). However, each user can also have additional emails. ...
0
votes
0answers
16 views

Postgresql: Update or insert stuck

I'm running update-or-insert query on a table of approximatelly 3mln rows, 4 columns. Query is part of every day process, and for same days, the query stucks forever. It's just blocked. It's ...
0
votes
2answers
40 views

Postgres: difference between CTE and temporary table

In Postgres is there a difference between a CTE and a temporary table other than the fact that the CTE exists just for the context of one statement? Documentation says that Common Table ...
0
votes
0answers
19 views

Postgres equivalent of SQL Server recovery model Simple

I am migrating an SQL Server database to PostgreSQL. The original database recovery model is Simple, mainly because the log size and performance are issues. What are the recovery models of Postgres ...
0
votes
1answer
15 views

Clarification on UNION ALL of JSONB_EACH result

This function used to merge 2 JSONB and delete certain key when the value is null, refer to this question. CREATE FUNCTION jsonb_merge(JSONB, JSONB) RETURNS JSONB AS $$ WITH json_union AS ( ...
0
votes
1answer
15 views

PostgreSQL update and delete property from JSONB column

From this article, I tried to update or delete property of a JSONB column: CREATE TABLE xxx (id BIGSERIAL, data JSONB); INSERT INTO xxx(data) VALUES( '{"a":1,"b":2}' ); SELECT * FROM data; id | ...
-1
votes
0answers
26 views

Postgres 9.1 - Select Query is in waiting status

ps -ef | grep postgres | wc -l returning 86 processes (most of them are idle). And db postgresql.conf having max_connections = 1300 But, still select query is waiting (table not having any update / ...
1
vote
0answers
24 views

Postgres: Can't free space because I have no space

I have a Postgres DB that someone was brilliant enough to install in the log partition of my linux box. It has a serious index problem, with indexes ballooning up to 50GB per. As soon as I start ...
0
votes
1answer
18 views

Uniq join 3 tables with relationship table not uniq

I am using Postgres. I have 3 tables: table_1 id table_1_2 table_1_id, table_2_id table_2 id The problem is the relationship table table_1_2 is not uniq. I.e., table_1_2 will have the ...
0
votes
1answer
20 views

What limits the number of connections?

As per https://devcenter.heroku.com/articles/heroku-postgres-legacy-plans the connection limit is 500 As per https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server "Generally, PostgreSQL on ...
1
vote
1answer
25 views

Can the number of tables and functions affect performance? [closed]

I have some big database with hundreds of functions and tables. They also have a lot of sequences, custom types and some views and triggers. There is a point when the quantity of objects will be a ...
0
votes
0answers
13 views

Getting SSL Working

So, I'm trying to configure PostgreSQL to allow SSL connections, on a Windows box. First, per http://www.postgresql.org/docs/9.4/static/auth-pg-hba-conf.html I added this line to pg_hba.conf (and ...
0
votes
1answer
16 views

Could this ActiveRecord/SQL statement in my code base be susceptible to SQL injection?

I was reading up on SQL injection attacks from the Rails Guides and was wondering if the below line could be susceptible to a SQL Injection attack: accounts.where("lower(name) LIKE ...
1
vote
0answers
20 views

Is C collation suitable for my Postgres database?

I am working with 500m rows (120GB) in Postgres 9.4, and I am trying to make SELECT statements as fast as possible. I am less concerned about the speed of INSERT and UPDATE, because my data only ...