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)

-1
votes
1answer
31 views

How to update values from bytea to varchar in Greenplum?

I need to convert hexa to values and need to update the values in a varchar field, I have tried: select pg_catalog.decode(column,'hex') The above code converted hexa to values but when I try to ...
2
votes
1answer
38 views

Dropped an index and recreated it in PostgreSQL 9.2, not used anymore

I have a table with 15M rows, with two indexes; one of them is a very simple BTREE on a string column. While trying to optimize some queries, I created a new partial index on the same column. Using ...
0
votes
1answer
18 views

Optimizing for Modulo Queries

I have a use case where I want to be able to query tens of thousands of records for the modulo of a certain field value with another number, i.e. queries like SELECT * FROM EVENTS WHERE MOD(OFFSET)=5 ...
0
votes
0answers
11 views

hstore type does not exist with hstore installed postgresql

I recently had to copy over a databases structure from one database to another with the command pg_dump -c -S database_name > pg_dump_date.sql I then ran the dump file on the new database with ...
0
votes
1answer
31 views

Slow Postgres updates if OTHER columns are indexed?

Certain updates take far too long on large Postgres tables. Given these conditions: only one column is being updated, and it is non-indexed the column already has data in it for every row due to a ...
0
votes
1answer
11 views

Adding hstore entries to an uninitialized column

I got bitten by this 'feature' recently. If your hstore column is uninitialized and you start adding entries to it, they are all silently swallowed without error. Is this expected? create table ...
0
votes
0answers
24 views

How to make pg_dump skip extension?

This is on 9.3 but I can remember simillar things happening since 7.x. So I create database and install plpgsql extension into it. Later on I create a pg_dump and before restoring it into databse I ...
3
votes
1answer
48 views

Counting repeated occurences for a group of fields

I am trying to count the continuous repeated value for a field in order to obtain the maximum repeated occurrences for each person in the table. eg: Time person Result 08:12:36 ...
0
votes
0answers
29 views

How to Insert records from remote database to local database using dblink in postgresql 9.3

I have a scenario like i have a two DB, one resides in remote server and other resides local. Now i have to fetch the records from remote DB when new records are inserted on tables (in remote DB) and ...
2
votes
0answers
54 views

Why is the CTE much worse than inline subqueries

Im trying to better understand how the query planner work in postgresql. I have this query: select id from users where id <> 2 and gender = (select gender from users where id = 2) ...
0
votes
2answers
37 views

Alter table statement waiting (for hours, on dev machine), but no locks shown

I have been trying to issue a simple: ALTER TABLE tablename ADD COLUMN id_col character varying (30) type statement on a Postgres 9.1.13 build on Debian. The application is still in private beta, so ...
0
votes
0answers
37 views

Querying really slow Postgres

I have multiple tables on Postgres wit GIS and when I query SELECT * FROM rxmsg JOIN Vehicles ON rxmsg.vid=Vehicles.vid JOIN stops on ST_DWithin(rxmsg.point, stops.point,1000) JOIN drivers ON ...
1
vote
0answers
19 views

Postgres drop type XX000 “cache lookup failed for type”

I'm currently working on a PostgreSQL 9.2.x Database with a lots of Clients, and tables and functions. We deploy code constantly and sometimes it is necessary to even drop a type or a function due ...
2
votes
1answer
22 views

Is it safe to use set-returning sql functions instead of security-barrier views?

Since 9.2, it's been possible to use the security_barrier attribute to guard against maliciously-chosen functions and operators accessing data 'hidden' behind filters in views (full info in the ...
1
vote
0answers
16 views

Postgresql service run failure

Trying to setup replication through the wal shipping using Postgresql 9.3 x64. Used this instruction from youtube. The problem is - the slave postgresql service won't run. This is what in logs ...
0
votes
0answers
15 views

How to copy remote database to local cluster using pgAdmin over SSH tunneling with Postgres 9.x?

I have successfully gotten pgAdmin on my development machine to do ssh tunneling over the internet to my production server. I can see the remote database and browse its tables and such. ➥ How to suck ...
0
votes
1answer
16 views

Moving Local PostgreSQL 8.4.20 Database to Amazon EC2 or RDS

I'm running PostgresSQL 8.4.20 on a local server and plan to migrate the data to either Amazon EC2 or RDS. I have working knowledge of databases and need advice from experts. I've been researching ...
0
votes
0answers
12 views

Getting PAM-compatible password hashes from pgcrypto

I want to keep user records in Postgres database and faced one issue which block me. It is password encryption. For example, this is correcetly encrypted password 12345 via default Ubuntu crypt ...
1
vote
1answer
60 views

Slow max, min query in Postgresql View

I have a view and it's a left join between two tables (table_a has hundreds of millions of rows, table_b has ~2 millions). The query SELECT MIN("id") AS "min_id",MAX("id") AS "max_id" FROM "the_view" ...
0
votes
0answers
19 views

PostgreSQL Idle Session in Transactions with RELEASE_EXEC_SVP queries and lock

I am having a problem with having idle sessions in transactions. In pgAdmin Server Status, it is showing "RELEASE_EXEC_SVP_XXXXXX" (XXXXXX data are varied) as its query and it's locks also contain a ...
3
votes
1answer
35 views

How do you truncate a `date` (not `timestamptz`) to month?

Postgres has date_trunc which operates on timestamp or interval, and: Values of type date and time are cast automatically to timestamp or interval, respectively. In other words we can use ...
1
vote
2answers
49 views

How to calculate the cumulative difference between rows in Postgres?

I am in need of calculating the difference from the cumulative values for the previous day in Postgres based on session_id. Example as mentioned below: Date session_id upload_usage ...
1
vote
0answers
22 views

Is there a parser for Postgres' auto_explain to make it easier to read and understand?

We have a number of Postgres Functions that each call a number of other Postgres Functions. If you simply EXPLAIN ANALYSE a call like SELECT parent_function(), the output is minimal, since it doesn't ...
1
vote
1answer
43 views

How to remove object from json array?

My table: CREATE TABLE items ( id BIGINT PRIMARY KEY NOT NULL, name VARCHAR, images json ); images format: [ { "id": "owner", "full": "<url>", "thumb": ...
0
votes
1answer
26 views

Database storage limit for open source PostgresSQL

I just started using PostgresSQL. When I installed SQL Server Express years back, you typically had a database storage limit if you didn't install the full version. I think I remember it being 4GB, ...
0
votes
1answer
24 views

PostgreSQL - retrieving max primary key column to insert a new row - any alternatives?

We are using a software that needs to request the max primary key column value to add a new row into the table that was requested. I know that there are some alternatives like: Sequences, and GUIDs ...
0
votes
1answer
26 views

“explain analyze” cannot get detailed analyzed results for queries in a plpgsql function

I am using postgresql 9.3 I have a function (Pl/PgSQL) created with serveral complex queries inside. For example, create function f1() return integer as $$ declare event tablename%ROWTYPE; .... .... ...
0
votes
0answers
23 views

Slow query on large table after new column is added

I have a table with more than 30 million records, and I recently added a new column with type text. ALTER TABLE database.b ADD COLUMN x TEXT; CREATE INDEX CONCURRENTLY idx_x on database.b(a, x); ...
0
votes
1answer
57 views

Connect to PostgreSQL via a ssh tunnel using Cygwin

I would like to connect to a Postgres server installed on a remote server using an ssh tunnel. I have Windows so I use cygwin for SSH. I do the following on cygwin: # Create the tunnel ssh -f ...
2
votes
3answers
91 views

Return total number of rows and selected (aggregated) data

I have a function which is selecting some data from a table. I would like to return the selected data and the total number of rows in that table. How can I do that or how can I get the same result in ...
1
vote
2answers
46 views

postgres function extract from date returns double precision value

Why does postgres function extracting from date return double precision value? Only reason I could imagine is, there are some locales using calendars (those not Gregorian calendars and supported by ...
0
votes
0answers
19 views

migrate standalone postgresql database cluster to high availability cluster

We have tested one setup of postgres HA with repmgr and pgpool. It is working fine and now we have to migrate our existing database to the HA setup. We have two approaches, Make the HA master as ...
0
votes
2answers
55 views

Logging in to phppgadmin remotely Ubuntu 14.04 Amazon EC2

I created an Ubuntu server instance on Amazon EC2 and installed php, postgreSQL, phppgadmin, and any other required features. After SSH'ing into the server using command prompt, I executed the ...
0
votes
0answers
33 views

Best practice for select or insert into [duplicate]

I was looking for quite some time on whats the best way of selecting or inserting some data. I have two tables: ReportData: report_data_id(pk), source_id(fk), value1; Source: source_id(pk), ...
0
votes
0answers
26 views

User with Connect privilege can create tables [duplicate]

postgres=# \list+ List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | ...
2
votes
1answer
28 views

WAL files are not copied

I'm using postgres 9.3 on Ubuntu 14.04 and I'm currently setting up a WAL backup. These are my changes to the postgresql.conf: [as described here: ...
1
vote
1answer
69 views

Using EXCEPTION to ignore duplicates during bulk inserts

In pq 9.3.5, I'm importing records from an external source where duplicates are VERY rare, but they do happen. Given a readings table with a unique compound key on (real_time_device_id, recorded_at), ...
0
votes
1answer
28 views

Query with column data for a max

In Postgres, I have a table like this: Column | Type | Modifiers ...
0
votes
0answers
14 views

Is it possible to create materialized view based on another materialized view in postgres?

I have a very large table and I summarize it in a materialized view. I then create an even smaller materialized view based on the earlier mview. The second mv is always showing zero rows. Is there a ...
0
votes
1answer
47 views

connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host

Hello I am trying to run a website sent to me but after doing so this error appeared connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "4X.XXX.XX.XXX", user "userXXX", database ...
2
votes
2answers
75 views

PostgreSQL joining using JSONB

I have this SQL: CREATE TABLE test(id SERIAL PRIMARY KEY, data JSONB); INSERT INTO test(data) VALUES('{"parent":null,"children":[2,3]}'); INSERT INTO test(data) ...
0
votes
0answers
31 views

Best way to store a function map

I am building a site where data gets filtered through user defined functions to create an output. It is a requirement that the functions are represented in the database as formulas. For example a ...
0
votes
0answers
19 views

PostgreSQL: Store hierarchial data and return a recursive result with full path data

Background: I am considering whether to use LTREE or Recursive CTE with Materialized Path. For storing data, I am deciding between HSTORE or JSON. Objective: I need to store a hierarchial data. Each ...
1
vote
1answer
40 views

PostgeSQL 9.3: What is the difference between text and pg_catalog.text?

I have a classic 3-environments setting (dev, staging and production), each with its own RDS PostgreSQL 9.3. The client/server versions are psql (9.3.5, server 9.3.3). In order to keep the schemas ...
1
vote
1answer
46 views

PostgreSQL, UPDATE CASE statement uses huge amount of space

I am running a CASE statement on one of my tables and it consumes a huge amount of hard drive space that is never freed up even when i run VACUUM ANALYZE. Autovacuum is ON as well. I am using ...
0
votes
0answers
68 views

ERROR: relation “name” does not exist

I am trying to import a postgresql database table sent to me in phpPgAdmin, I am following the instruction from this import database But after doing so, several error appear, I also tried to import ...
3
votes
1answer
148 views

Get list of characters in column

I have a database table (UTF-8) with a lot of names in different languages with lots of special characters. In another script I use these names and one part is to replace the special characters. To ...
0
votes
1answer
31 views

Dump all binary columns from a table as files

I have a table in a postgresql database with a column of type bytea. I want to drop each binary entry as a file using the id as filename. What would a SQL query look like for this?
0
votes
2answers
132 views

Performance Benchmark - MySQL vs PostgreSQL [closed]

this is my first question here in DBA. I wish to do a performance comparison between MySQL and PostgreSQL using same database on the basis of total time taken to parse + execute + send result back ...
0
votes
1answer
28 views

Postgresql - Streaming replication - STONITH

Current situation: PostgreSQL, streaming replication Master failed, I created the trigger file. Slave is promoted to new master After the old master restarted successfully, I have to create base ...