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
25 views

Access operator added by extension inside a schema

I am writing an application that uses postgres. Each microservice uses its own schema inside the database. So connect to the database schema I use this jdbc string: ...
0
votes
1answer
36 views

Postgresql regex match all digits in column

How do I extract all digits from a string with regex in pgsql? select regexp_matches('dsa8a552a5a2a5?', '\d+'); Will output only 8. Need to get 8552525
0
votes
1answer
46 views

improve long running query

I have this query INSERT INTO interactions( user_id, external_object_id, origin, interaction_type, interaction_sub_type, published_at, origin_id, created_at, updated_at) SELECT ...
8
votes
0answers
217 views

Avoiding “Row by row” fetch method when dealing with source LOB columns

I have a legacy PostgreSQL database source (ODBC) that I'm attempting to migrate to new SQL Server schema using SSIS. I'm getting a warning saying: 'Row by Row' fetch method is enforced because ...
0
votes
1answer
65 views

Divide a PostgreSQL database into schemas

My Postgres database will be focused on multidisciplinary organizations. The project axis is: a person could belongs to diverses disciplines (ex: arts, sports) for the same organization, and this ...
0
votes
2answers
28 views

Table constraint, number of row taken by a fk key

Is it posible to add a table constraint, to prevent an insert if there are already 3 row of the same fk key My table: ProjectTitles (id(pk), project_id(fk), title_id(fk)) Check if project_id has ...
0
votes
1answer
15 views

backup postgresql database to submit with project

I have a final year project written in Matlab in conjunction to a postgresql database called 'hm'. I asked in which way could I submit the database and I was told to perform a back up of the database ...
1
vote
1answer
173 views

Postgres 9.4, replication slots, doesn't work failover master

I've installed postgres master and slave nodes by this manual: At the master (10.0.0.1): sudo -u postgres initdb -D /data/postgres/main Change postgresql.conf: listen_addresses = '*' wal_level = ...
0
votes
0answers
21 views

doing a insert while selecting an specific user

I'm importing and legacy database to a new database, and changing data format. In this legacy database, I have data as following: Interaction id: 5458d717cd07870859000004 user_id: ...
7
votes
5answers
3k views

SELECT DISTINCT on multiple columns

Supposing we have a table with four columns (a,b,c,d) of the same data type. Is it possible to select all distinct values within the data in the columns and return them as a single column or do I ...
0
votes
1answer
123 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
1answer
199 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
87 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
60 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
0answers
38 views

Why postgresql pg_dump exports a view as a table?

I am using postgresql 9.3 pg_dump tool for extracting only the public schema definition using: pg_dump -s -n public -h host -U postgres --dbname=db > ./schema.sql but when I check schema.sql one ...
0
votes
1answer
53 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
84 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
50 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
43 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
2answers
55 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
23 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
107 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, ...
3
votes
1answer
70 views

PostgreSQL bytea vs smallint[]

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
40 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
67 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
1answer
56 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 ...
9
votes
1answer
541 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
1answer
58 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
vote
1answer
126 views

Could not connect to postgres after installing 9.4 and uninstalling 9.3

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
80 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
50 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
68 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
37 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
41 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
51 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
99 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
25 views

Conditionaly query in postgresql function

I have a simple query below : CREATE OR REPLACE FUNCTION companies_all_teams( ...
0
votes
1answer
27 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
53 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
39 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
57 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
28 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
35 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
21 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
26 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
35 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
1answer
19 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
51 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
38 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
55 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 ...