All versions of PostgreSQL. Add a version-specific tag like postgresql-9.4 if that context is important.

learn more… | top users | synonyms (1)

0
votes
1answer
39 views

After renaming postgres user, getting “role 'postgres' does not exist” in logs on PostgreSQL startup

For security reasons, we've been asked to rename our postgres user in our database. We've made the change in our staging environment and bounced PostgreSQL. We're now seeing an error in the log on ...
0
votes
0answers
29 views

Postgresql Encryption by middleware

I am trying to encrypt a Postgresql database to fit some new requirements. The applications accessing this database are already in production and I would prefer to not make changes to them. I have ...
0
votes
1answer
22 views

PostgreSQL: access right problems

I have a "production" user and database on which I want to give right access on all the users belonging to a production group. Unfortunately, I don't succeed, keeping the access denied error. Can ...
0
votes
0answers
21 views

Does JSONB column type in export look identical to JSON?

In other words, does it export as text or as a binary blob. I'm running pg_dump. I'd love to see the text version of the JSON data, not some kind of encoding of a binary blob.
2
votes
0answers
89 views

Server Doesn't Listen Error when connecting to PostgreSQL from Client

I have done a lot of research through the Google and have not been able to come up with a solution. I installed PostgreSQL 9.5 and PostGIS 2.1.8 On Ubunutu Server 14.04 and configured PostgreSQL as ...
3
votes
1answer
34 views

Queries show data but not column names

I'm getting through the postgresql tutorial, I've created my db, 2 tables, weather and cities and added a few lines of data. When I query my db with this sql statement for example: SELECT city, ...
2
votes
1answer
34 views

What is preventing DROP TABLE from removing a Postgres table? [duplicate]

I have a postgres database named aarons_db in ubuntu linux. I'm trying to delete a table called pnt within aarons_db. To do this, I am using the following command: DROP TABLE pnt Unfortunately, ...
5
votes
2answers
341 views

CREATE as SELECT with CONSTRAINT?

I have a piece of SQL that creates a TABLE form a SELECT statement in PostgreSQL ; I want to add constraints to the table so that for example a column cannot be null. I cannot find valid SQL for this ...
2
votes
2answers
70 views

PostgreSQL Server: Many-to-One replication / Transactional Replication

I have several PostgreSQL DBs in different geographical locations (local sites). Each local site DB have the same schema, but unique data. For example, Take a table with columns: Site_ID, ...
1
vote
1answer
31 views

Postgres/pgloader: setting a delimiter for multiple line text records

I wish to import a 5 gigabyte text file with pgloader. The individual records are paragraphs of html. The records include carriage returns and white space. So this not an import where it is one ...
0
votes
2answers
49 views

should I denormalize for user profiles?

Assuming the choice is to stay with relational model, how are tables structured in the case of large User profiles? All the examples I see consider only simple cases, such as a "profile" containing ...
1
vote
0answers
45 views

PostgreSQL doesn't use index on inherited tables

I have two tables in PostgreSQL 9.4.5 deployed on Amazon RDS: an append only, weekly partitioned, All Positions table. These store all position readings from about 100,000 sensors. There are about ...
6
votes
2answers
87 views

Which executes first? Trigger or rule?

Using PostgreSQL. Had a trigger which does something after delete and made a rule which stopped delete from happening if something will be true. My question is: will the rule prevent the trigger ...
3
votes
2answers
43 views

Array integer[]: how to get all distinct values in a table and count them?

I'm not so good with SQL (PostgreSQL). Here is what I want to do: I have a table, fields: id SERIAL inet INET ports integer[] id | inet | ports ----+------------+------------ 2 | 1.2.2.1 ...
4
votes
1answer
31 views

Dynamic form builder database optimization Postgresql

Hi I have a project that create forms dynamically I use a model like the following: forms ----- id (PK) name (other fields) form_fields ------------- id (PK) form_id (FK to forms.id) ...
0
votes
0answers
15 views

Best approach to maintain a clone of a db in Postgres RDS

We'd like to maintain a separate database for our dev environment that closely resembles the current state of our production database. What is the best way to do this in RDS? Our current process is to ...
1
vote
1answer
26 views

Postgres Access Roles

I'm trying to get my head around postgres roles. I want to create a database and have the owner role have all privileges on the database. I then want another role which cannot create tables but able ...
0
votes
0answers
24 views

Does Postgresql have a transaction log?

My question is pretty simple; does postgresql have something similar to the transaction log in SQL Server? If so, how do you access it to truncate dead transactions, or set what size it should be? ...
0
votes
1answer
66 views

how can we merge sum and count? [closed]

My result of the request of group by is : ref state quantity total PO3253 assinged 300.0 323400 PO3253 done 300.0 323400 When I delete state from ...
1
vote
1answer
27 views

What determines whether `pg_dump` includes a varchar length?

I work on a project where we regularly dump our Postgres database schema and commit it in the project repository. However, depending on which developer dumps the schema (via pg_dump), varchar columns ...
0
votes
1answer
43 views

pgbouncer 1.7 with TLS/SSL client and server connections

With settings borrowed from a similar server running Postgres 9.4.1 & pgbouncer 1.6.1, I have multiple users connecting to the database through pgbouncer on port 6543. I also have a second server ...
1
vote
2answers
43 views

What is table bloating in databases

Can someone explain what bloating means in database terms. For example what does it mean to say an index is bloated. I tried searching for it but there is no explanation of what bloating is . Only ...
3
votes
3answers
74 views

SELECT + INSERT or INSERT alone

I have an application where several devices send data every second to my server. On the database I have a table with the devices and another table with the data sent every second. The first time a ...
1
vote
1answer
36 views

Help with adding a time filter to Postgres query

I've asked this question over in SE GIS, but told it would be better suited to this SE, so here goes... I know Postgres is brilliant for grouping points based on their spatial values - that I can do ...
-4
votes
1answer
34 views

How to return a single column value using a PostgreSQL function? [closed]

I want to return a single column value in PostgreSQL function from a PostgreSQL database. How can I achieve that?
3
votes
1answer
37 views

Find current owner of custom data type?

In Postgresql, when I try to run ALTER TYPE x ADD VALUE y; on a custom datatype I get an error stating PG::Error: ERROR: must be owner of type x. I know this can be solved by running ALTER TYPE x ...
1
vote
2answers
40 views

How to set roles and users with correct permissions on Postgres? [closed]

My current database uat has as owner postgres. But now I would like to set roles and users with the correct permissions. Something simple like: roles: dba, developer, application users: dba1, dev1, ...
2
votes
1answer
55 views

What are the consequences of dropping or changing the user name for the postgres DB account?

I feel confident I understand what's involved at the db level: If dropping, I'd need to create users for each sys admin, give them SUPERUSER, and then drop the postgres user. If changing the name, ...
0
votes
0answers
43 views

Updated Financial Database Design

I took the design that @Daniel Hutmacher suggested in question below: Financial database design I amended it as to what I need below: -- Companies CREATE TABLE companies_list ( [code] int NOT ...
0
votes
0answers
22 views

Postgres: Recreate TRIGGER after replacing function?

Given a function like this: CREATE OR REPLACE FUNCTION foo() RETURNS TRIGGER AS $$ BEGIN -- do something fancy END; $$ LANGUAGE plpgsql; which is used in a TRIGGER: CREATE TRIGGER bar ...
1
vote
1answer
42 views

Performance issue using view vs. direct statement

I have a table with structure similar to this: table values ( id1 int, id2 int, value real, value_at timestamp, constraint primary key (id1,id2,value_at) ) I need to get the "current value" for a ...
2
votes
1answer
33 views

How to optimize this query on Postgres

I'm trying to make a relatively simple query, but it's taking much longer than I'd expect. I have an index in place, but it doesn't seem to be helping much. Here's the query. It sometimes takes up to ...
1
vote
1answer
50 views

Index performance for CHAR vs VARCHAR (Postgres)

In this answer (http://stackoverflow.com/questions/517579/strings-as-primary-keys-in-sql-database) a single remark caught my eye: Also keep in mind that there's often a very big difference between ...
-4
votes
0answers
75 views

how to get one of the values in group by?

For the following tables stock_moves product_id purchase_line_id state product_uom_qty ----------------------------------------------------------- 4018 1230 assigned ...
1
vote
2answers
331 views

Complex view becomes slow when adding ORDER BY in outer query with small LIMIT [closed]

I have a pretty large query in a view (let's call it a_sql), that is really fast unless I use ORDER BY in an outer SELECT with a small LIMIT: SELECT customs.id AS custom_id, customs.custom_name AS ...
11
votes
2answers
79 views

PostgreSQL Recursive Descendant Depth

I need to calculate the depth of a descendant from it's ancestor. When a record has object_id = parent_id = ancestor_id, it is considered a root node (the ancestor). I have been trying to get a WITH ...
2
votes
1answer
26 views

OFFSET and LIMIT on complex query

I am doing a pretty complex query in Postgres 9.3.4: SELECT p.* FROM unnest('{19082, 19075, 20705, 18328, 19110, 24965, 18329, 27600 , 17804, 20717, 27598, 27599}'::int[]) ...
0
votes
0answers
6 views

Using start and end event logs to create a table/view containing spans between the times of each log [duplicate]

To be specific, I have an event table that logs when a user joins or leaves a team. It looks something like the following: ------------------------------------- | user | event | team | timestamp | ...
0
votes
3answers
51 views

Using start and end event logs to create a table/view containing spans between the times of each log

To be specific, I have an event table that logs when a user joins or leaves a team. It looks something like the following: ------------------------------------- | user | event | team | timestamp | ...
1
vote
1answer
39 views

In PostgreSQL, will VACUUM reset the dead tuple count (n_dead_tup in pg_stat_all_tables)?

In PostgreSQL, will VACUUM reset the dead tuple count (n_dead_tup in pg_stat_all_tables)? The situation I'm seeing is that vacuum is apparently being run manually, once daily, and the n_dead_tup / ...
2
votes
2answers
46 views

select/union output from two columns into three

I'm sure there is an easy answer to this, but my PostgreSQL isn't up to it at the moment. I have a table hostname_facts with three columns: hostname name value hostname is a list of ...
1
vote
1answer
50 views

PostgreSql : flatten json array data

From my current query, I obtain this jsonb data : values: "a1", ["b1", "b2"] And I want to flatten it on one level only, like this : values: "a1", "b1", "b2" Here is a simplfied way to get ...
0
votes
1answer
30 views

Will this SQL snippet REINDEX my GIN index? Why is it renaming an old index onto another?

I have a large PostgreSQL 9.3 database. One index on one table is quite large and appears to be bloated. I am using pgcompact from pgtoolkit to reduce database bloat without heavy table locks. However ...
2
votes
2answers
48 views

How to unite 2 subqueries to reduce retrieving data from cumbersome tables?

There are 3 tables: user, conversation, message. Table user: id, login, last_login_time (time of last user's login), ... Table conversation: id, user1_id, user2_id, ...
0
votes
0answers
47 views

How can a select max query return no rows?

I have a process that selects the maximum date from a Greenplum (PostgreSQL 8.2) table, and coalesces it to a default value. Once, and once only, this query returned 0 rows. How is this possible? Even ...
0
votes
1answer
25 views

psql variable holding text with multiple lines

This works as expected, \set x '''2\n3''' but this doesn't \set x '''2 3''' Is there a workaround for later example so I don't have to use \n instead of newline?
0
votes
0answers
7 views

Debian Server failover setup

I need to set up two servers with failover capability (Active - Passive model) sharing a common DB (Postgres)running over NAS. Could you please suggest me some workaround for the same ?
0
votes
1answer
27 views

Migrate Oracle BLOB to Postgres BYTEA or OID [duplicate]

After the BLOB columns of Oracle (11g r2) tables are migrated into a Postgres (9.4.5) table such as using Ora2Pg, I have two questions: 1) Which data type will the new column assume, is it BYTEA or ...
2
votes
1answer
45 views

PostGIS - indexing - speed up query

I have this query (called from PHP, hence the $ variables): SELECT a.name, St_AsText(a.geom), b.name AS name_b, b.id FROM a LEFT JOIN b ON b.id = a.b_id WHERE ...
1
vote
1answer
31 views

PostgreSQL: Restoring 1 file from a directory format dump

I've got a large'ish (> 700GB) PostgreSQL database. I'm working on importing it into AWS RDS. I realize there are modules that will cause problems, we're dealing with that separately, so for right ...