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
1answer
6 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 ...
1
vote
1answer
122 views

Mysterious inequality behavior when comparing date strings

Can someone explain this mysterious Postgres behavior? I'm performing the following queries at the psql command line. mydb=> select '20150526' > '2015-05-25'; -[ RECORD 1 ] ?column? | t ...
3
votes
1answer
25 views

Query the definition of a materialized view in Postgres

I'm wondering how to query the definition of a materialized view in Postgres. For reference, what I hoped to do is very similar to what you can do for a regular view: SELECT * FROM ...
1
vote
0answers
8 views

pg_restore fails with materialized view

I’m trying to pg_restore a db dump that contain a materialized views. If it is relevant, the materialized view is of a foreign data wrapper. It fails with the following errors: pg_restore: ...
0
votes
1answer
42 views

GROUP BY very slow when returning many rows

I have a query to aggregate data per day. When I run the query for a single day it is very fast. However, when I run the query for multiple days the time cost increases much faster than ...
0
votes
1answer
21 views

Is it possible to select distinct values in a json document using PostgreSQL?

I have a column that is using the JSON type. I would like to perform a query to select all distinct records for a particular field in the JSON string: I.e. given these three documents { id: 1, s: ...
1
vote
0answers
27 views

Master/Slave - streaming replication restrict function to master

How can I run a function a on master only? I don't want to connect directly to my master server, because the master server might change. Or can I change my function to work on this setup? Because ...
0
votes
1answer
37 views

Why would you need a tablespace?

I learned how to create tablespaces, rename it, assign an owner to it, and drop it. But I don't understand why I would even need it. A tablespace is simply a storage area on disk assigned to a ...
1
vote
1answer
24 views

Speed up creation of Postgres partial index

I am trying to create partial indexes for a large (1.2TB), static table in Postgres 9.4. My data is completely static, so I am able to insert all data, then create all indexes. In this 1.2TB table, ...
0
votes
0answers
18 views

PostgreSQL updates hang when two servers involved

I have an update statement that works fine when only a single server is involved, but never completes when it comes from two servers. I'm connecting with JDBC 9.1-902 to a 9.3 database on CentOS 6.6. ...
9
votes
2answers
76 views

How often will a FOR EACH STATEMENT trigger execute if the operation is caused by an FK constraint with UPDATE CASCADE?

I understand that a trigger on table t defined with FOR EACH STATEMENT will run once when I execute an UPDATE t .... Now, when t is defined with FOREIGN KEY ... REFERENCES a ... ON UPDATE CASCADE, ...
2
votes
0answers
27 views

PostgreSQL bytea vs

I'm looking to import large (100Mb -- 1 GB) multi-channel time-series data into a PostgreSQL database. The data comes from EDF format files that chunks the data into "records" or "epochs" of typically ...
0
votes
1answer
28 views

Why have both a postmaster and postgres executable?

It's a little confusing how you have several executables to start postgresql, e.g. postmaster, postgres, pg_ctl. postmaster -D /usr/local/pgsql/data postgres -D /usr/local/pgsql/data pg_ctl -D ...
0
votes
1answer
25 views

How should I index a UUID in Postgres?

I'm new to PostgreSQL and somewhat new to databases in general. Is there an established way of how we should index UUIDs in Postgres? I'm split between using hashing and using a trie, unless there's ...
0
votes
0answers
33 views

Ongoing Administration comparison PostgreSQL vs Firebird [on hold]

I am trying to decide between these 2 database systems for a project. I have frequently read that Firebird requires practically no ongoing administration once it's set up. Does PostgreSQL require ...
0
votes
1answer
24 views

How to remove data from multiple tables with different foreign keys without using ON DELETE CASCADE?

I have the following SELECT statement: SELECT * FROM "Users" u INNER JOIN "Calendars" c ON (u."UserId" = c."UserId") INNER JOIN "Actions" a ON (c."CalendarId" = a."Calendar_CalendarId") WHERE ...
8
votes
1answer
396 views

Why is SELECT * much faster than selecting all columns (in a different column order) by name?

On a table with columns a,b,c,d,e,f,g,h,i,j,k I get: select * from misty order by a limit 25; Time: 302.068 ms And: select c,b,j,k,a,d,i,g,f,e,h from misty order by a limit 25; Time: 1258.451 ms ...
1
vote
0answers
35 views

Postgres not using the index even when rows returned is 5% of the table

I have a postgres table with the following structure: +---------+-------------+-------------+----------+---------+---------+ | id | timestamp | numvalues | text1 | text2 | text3 | ...
-1
votes
2answers
18 views

psql: could not connect to server and socket /var/run/postgresql/.s.PGSQL.5432

I have installed postgresql 9.4 and I removed postgresql 9.3 from my computer. Now when I try to run: foo@bar:~$ psql I get the error psql: could not connect to server: No such file or directory ...
0
votes
1answer
26 views

could not open log file “/var/log/postgresql-2015-05-24_181212.log”: Permission denied

I installed postgresql from source on Ubuntu 14.04 (I also installed from repositories too before, I just want to get a feel for both of them right now, as I will heavily rely on this database). So ...
0
votes
1answer
27 views

Multiple database directories with postgresql

I installed postgresql from source on Ubuntu 14.0.4. It is located in /usr/local/pgsql. At first, I created a data directory at /usr/local/pgsql/data and then ran initdb -D /usr/local/pgsql/data I ...
0
votes
1answer
35 views

How to execute two transactions concurrently in PostgreSQL?

I want to execute two transactions concurrently in pgAdmin: --The first transaction should modify the age of Paul BEGIN; DECLARE newage INTEGER; --the original age of Paul is 32 newage := Select age ...
0
votes
1answer
11 views

PostgreSQL ODBC and Microsoft Access date/time in aggregate functions

I am trying to replace our MS Access 2003 databases with PostgreSQL 9.3. The first step is to use our MS Access front end to the upsized databases in PostgreSQL. Everything seems to work very well ...
1
vote
1answer
37 views

Performing search on a column by query

Up until today I've used LIKE %term% to query for rows on particular column term. Then I've read about FULL TEXT index. And I think I misunderstood how Full text index works. I have an API that ...
0
votes
0answers
23 views

Is there some tricks to better index a URL column in postgres?

I'm working with a table that needs fast retrieve rows by its url column. But they all will be starting with http://www.: http://www.google.com http://www.amazon.com http://www.stackoverflow.com I ...
0
votes
0answers
26 views

Postgres 9.4 - How to really grant all privileges on a database to another user?

Just a heads up, I'm fairly new at this whole DBA thing. Okay, with that out of the way I've been struggling mightily lately with granting access to a database in postgres to a user. Let's call the ...
0
votes
0answers
22 views

Conditionaly query in postgresql function

I have a simple query below : CREATE OR REPLACE FUNCTION companies_all_teams( ...
0
votes
1answer
16 views

PostgreSQL: a Login Role which can select from any Views

I need to write a SQL file which must do the following: create a role called 'selection' grant connect/usage to the current database grant select/execute to all views of all schemas (or at least on ...
0
votes
0answers
30 views

Postgres uses a lot of cpu

First of all, I am a bit newbie in case of postgres database but I was requested to check this out. The problem is that postgres processes occupy time to time almost 100% inside the linux system - I ...
0
votes
0answers
28 views

Postgres Query Optimisation (Rails App)

I have a very slow running SQL query that is run from my Rails app using the Model.find_by_sql method. I've made a number of optimisations but it's still extremely slow. It would be great if anyone ...
2
votes
1answer
20 views

Postgresql: Aggregate objects into an (json) array (subquery issues)

I'm sorry for the vague title, but I simply don't know the right words to describe this. I have this query that transforms a bunch of columns into an object that works just fine: SELECT ...
1
vote
1answer
20 views

Spiky COMMIT results in performance slowdowns with Postgres 8.4

We just installed performance monitoring on our web application, and we're seeing a spiky pattern in response times from our Postgres 8.4 server. The spikes correspond with significant slowdown in our ...
0
votes
1answer
24 views

PostgreSQL Backup and restore, sizes are different

I Have a Wordpress database in my postgreSQL, in phppgadmin this database is shown with the size of 273 MB. I've ran sudo -u postgres pg_dump -Fp -f wordpress.sql wordpress to do the database backup, ...
0
votes
1answer
11 views

How to update array fields in a table in Postgresql?

Say I have a table defined as following: CREATE TABLE my_tbl ( id bigint, a1 bigint[], a2 bigint[] ); I would like to create a stored procedure to append values to a1 and a2. Is this ...
2
votes
0answers
16 views

PostgreSQL query - works locally but not on AWS RDS

We have a large query that works fine locally but deadlocks on AWS RDS. According to cloudwatch we are not resource bound on CPU, disk or iops and nothing else should be accessing these tables. The ...
0
votes
0answers
22 views

how to migrate data between two distincts tables

I have a database with millions of records in a table users. I need to collect this data, tranform to a new format (removing a field, for example) and save it to another database. I'm currently doing ...
0
votes
0answers
28 views

Starting the Database Server postgres [closed]

OS X 10.10, postgres 9.3.5, installed from here I had to initialize the datacluster manually, as stated on the site, through $ /usr/local/pgsql/bin/initdb -U postgres \ That worked fine. At the ...
0
votes
0answers
17 views

Unable to point out Exact cause behind anonymous block failure(Postgresql) [closed]

DO $$ DECLARE customer_list varchar[]; customer_schema varchar(100); BEGIN customer_list=ARRAY(select cname from customer); -- Get a ...
0
votes
1answer
15 views

Use a value for a Postgresql setting in a trigger

We're using a trigger to track changes in various database tables. This works fine. Now we want to be able to track the changes back to the web request that caused them. I'd like to be able to use ...
0
votes
0answers
10 views

Print to console as SQL executes

When executing multiple SQL commands, such as in the pgAdmin SQL Editor, how can I print some strings to the console (output pane in pgAdmin). I want to monitor execution. UPDATE x SET a = b WHERE a ...
1
vote
1answer
26 views

Optimize view (and underlying table) for averaging timestamps into hours

I have this table: CREATE TABLE spp.rtprices ( "interval" timestamp without time zone NOT NULL, rtlmp numeric(12,6), rtmcc numeric(12,6), rtmcl numeric(12,6), node_id integer NOT NULL, ...
0
votes
0answers
33 views

Tuning a Postgres INSERT only database

I am designing a database which will have many inserts and selects, but no updates. Are there any considerations to take (in order to have high query performance) while knowing no tuple updates will ...
1
vote
1answer
17 views

List MATERIALIZED VIEWs in PostgreSQL that do not have a UNIQUE index

Postgresql 9.4 allows to REFRESH materialized views CONCURRENTLY, if they have a UNIQUE index. I am looking fo a SQL-query that lists all materialized views that DO NOT have such a UNIQUE or PRIMARY ...
0
votes
0answers
22 views

Postgresql indexing for IS NULL

I have two similar queries, whose only difference (in the last two lines) is that one uses IS NULL while the other compares defined values. Query #1 takes only a few minutes: UPDATE ...
0
votes
2answers
22 views

How to use Italian locale for Postgres messages

On Oracle I have set: export NLS_LANG=Italian_ITALY.UTF8 .. on Unix shell and now I get status and error message in Italian. How to set in Postgres shell (psql)? I have set: SET lc_messages TO ...
3
votes
1answer
89 views

How to index for timestamp queries

I have a products table where I insert around 150,000 records a day. Most of them are redundant, but I need to keep them because of the new expiration date. I get product feeds from about 5 vendors a ...
2
votes
0answers
22 views

Warm Standby PostgreSQL 9.4 error; FATAL: the database system is starting up [closed]

I want to setup a Master and a warm standby, so far here's what I have setup: Master postgresql.conf listen_addresses = '*' wal_level = archive archive_mode = on archive_command = 'copy "%p" ...
0
votes
0answers
38 views

How can I calculate the difference between my time column in seconds? [closed]

I have got a large database, one of the columns is the time with this format "08:27:22" and I am looking to find out the difference of seconds between the "open doors" and "close door" events. The ...
1
vote
1answer
47 views

Reduce the number of queries to the same table

I need to build some reports using two tables: AuthorTitles: id(pk), author_id, title_id AuthorReports: id(pk), author_id, title_id, items_sold, date My report needs to output the fallowing: ...
0
votes
1answer
21 views

Postgres: Disable “similarity” column output on “SELECT SIMILARITY”?

I've tried disabling similarity column output on SELECT SIMILARITY but still cannot. Below query will generate a column similarity: SELECT SIMILARITY(title, 'Nation'), title FROM gallery WHERE title ...