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
0answers
52 views

PostgreSQL: Slow JOIN on three large tables

Edit: Proposed this question as a LEFT JOIN problem, but as @wildplasser pointed out, due to my WHERE clause I was actually doing a JOIN all along. Adjusting the question from LEFT JOIN to JOIN. The ...
1
vote
0answers
46 views

The definitive fastest radius search query with Postgis 2.0

I come from mysql world. I read the manual and saw some examples, after that, I'm not able to say witch method is the fastest for a radius search. Nobody seems to agrees. My simple case: I need to ...
1
vote
0answers
113 views

PostgreSQL migrating from 9.2 to 9.5 with data dir on different volume

We have a problem in upgrading postgresql 9.2 cluster to 9.5 using pg_upgradecluster, because the data directory is on a different volume from the root one. At the beginning, we just tried: # ...
0
votes
0answers
23 views

Prevent Update/Insert/Delete based on Date

I have a simple Table that holds financial data with a date. I would like to endure, that historic values are protected to INSERT, UPDATE or DELETE. Example: All values of March 2016 should not be ...
0
votes
0answers
18 views

Diagnosing why postgresql query is going in a seemingly endless processing loop

I maintain a social forum built with Django and postgresql 9.3.10. There's a maintenance query I run via psql, to clean up my postgresql table. It goes like this: begin; DELETE FROM links_seen WHERE ...
0
votes
1answer
56 views

How to convert postgresql dump file into mysql dump file

I having Postgresql dump file like data.sql. I need to convert postgresql file into mysql dump file It is possible to convert without install postgresql database . Thanks in advance
1
vote
1answer
23 views

Top N Results Ordered by Joined Table Column

I'm trying to optimize a fairly simple query that just gets a list of the top N users ordered by the number of followers they have. I am running into performance issues when I run the query a certain ...
1
vote
1answer
29 views

Alias Column Name [closed]

I am trying to run a basic select Query in PostgreSQL, but I am having trouble using the column alias. I tried to create the alias as randomfield As [Space In Name] but it gave an error of Error: ...
2
votes
1answer
84 views

Aggregate count over variable number of json keys

How can one get a list of json objects like this: [ {"band": "beatles", "bass": 1, "drums": 1, "guitar": 2}, {"band": "metallica", "bass": 1, "drums": 1, "guitar": 2, "vocals": 1} ] from ...
1
vote
0answers
25 views

parallel pg_restore with materialized views

I am trying to restore a database that includes some materialized views. I am migrating from a standalone postgres installation to RDS. To troubleshoot the restore process, I have split the restore ...
0
votes
2answers
16 views

Only describing postgres tables with “\d” (not sequences, indexes, views, …)

I want to describe every table in a postgres database. Currently I have this: psql -d db -c "\d *" > db_description.txt But this also includes all sequences, views, etc. Is there a command ...
1
vote
1answer
33 views

Trigger for a particular row?

I am trying to dynamically create trigger for a particular row instead of for each row. So if a table has 1000 rows and I want notification only on 25 rows, I am creating triggers like: CREATE ...
0
votes
1answer
38 views

Updating column from another table - PostgreSQL 9.2 [closed]

There are two tables: ja_jobs junk.test_test1 I need to update the time_job column from junk.test_test1 to ja_jobs. Here is what I'm doing now: UPDATE ja_jobs t2 SET time_job = t1.time_job FROM ...
0
votes
1answer
14 views

select duplicated rows by modified_date - PGSQL 9.2

Query: SELECT j.id INTO junk.ja_jobs FROM ( SELECT time_job, recurrenceid, clientid, creatortype, deleted, MIN(id) AS id FROM ja_jobs WHERE clientid = 33731 AND creatortype = 'legacyrec' AND ...
0
votes
1answer
104 views

Trigger function - PostgreSQL 9.2

The idea: 1 - The customer can add any value into users.code column 2 - If the customer does not insert data into it, the trigger/funciton has to do the job I am able to do that, using this SQL: ...
1
vote
1answer
19 views

Remove accidental duplicates in PK table, cascade changes to FK table

Lets say I have three tables in a postgreSQL database, one of plants, one of samples, and one of mappings to change variables in plants. There is a PK-FK relationship between plants.id and samples....
2
votes
1answer
20 views

Multiple columns from one table rely on one single table

I'm working with PostgreSQL 9.2 and have the following relation between 2 tables: The table town stores a list of town codes. The table perimeter stores perimeters denomination. Towns are almost ...
0
votes
1answer
51 views

Start, stop, configure PostgreSQL through Mac terminal

I am having basic problems using PostgreSQL on my Mac OSX Yosemite, through the terminal. I tried google-ing but this is becoming increasingly difficult and info very scattered so I keep running into ...
1
vote
0answers
24 views

When was a table created? [duplicate]

Is there any way to find out when a table was created in PostgreSQL or Greenplum, other than finding the underlying table and looking at the OS creation timestamp?
0
votes
0answers
15 views

Remedying psycopg2:OperationalError in postgresql 9.3.10 database

I have a Django app + postgresql 9.3 DB, hosted on Ubuntu VM. Recently my VM ran out of disk space, resulting in no space left on device errors showing up in my logs. I cleared the space on the device ...
0
votes
0answers
5 views

Ubuntu: How to soft-link to the latest version of PostgreSQL CLI tools [duplicate]

I have just upgraded my RDS PostgreSQL version from 9.3 to 9.5. In order to access the server, I need to upgrade the Ubuntu CLI tools as well. I have upgraded the tools using the apt.postgresql.org ...
0
votes
1answer
25 views

Postgresql error: failed to re-find parent key in index

I haven't seen this before and am stumped. I have a Django app with a postgresql 9.3 DB (hosted on Ubuntu VM), and very recently I VM ran out of disk space (resulting in no space left on device ...
1
vote
1answer
13 views

Delete duplicated rows by modified_date - PostgreSQL 9.2

I've got some duplicated rows on a table called ja_jobs: To find those duplicated data, I'm running this Query: select * from ja_jobs WHERE clientid = 33731 AND creatortype = 'legacyrec' AND deleted ...
0
votes
0answers
28 views

How can I restrict users to see only tables they can SELECT from

I have a redshift database with many schemas and tables. I created a group of users and granted them with permissions to view (select) tables in some particular schema: CREATE GROUP data_viewers; ...
0
votes
0answers
10 views

postGIS out-of-db still has error when environment file is updated

I'm running postGIS 2.1 with a PostgreSQL 9.1.21 and am trying to get rasters back out of a database and am running into the error: ERROR: rt_raster_load_offline_data: Access to offline bands ...
2
votes
1answer
16 views

PostgreSQL read-only user for pg_dumpall

I'm running a PostgreSQL instance which is used by several related applications, each of which has its own database. For backups I want to create snapshots of the complete data in the instance and I ...
1
vote
1answer
21 views

How to make trigger function to make daily entering-exiting report?

I have a table called daily_report that register what time/date worker goes out from the building and what time/date he/she comes in. CREATE TABLE daily_report ( id serial, ...
0
votes
0answers
44 views

Improving query performance involving similarity and full-text search

I have been trying to improving the performance of this query involving similarity and to_tsquery. I have a table (440,000 rows, PostgreSQL 9.5.2) with the following characteristics: test_db=> \d ...
0
votes
1answer
27 views

Schema size [PG TOAST] - PostgreSQL 9.2

I've got the following query to measure the schema's size on my DB: WITH schema_size AS ( SELECT tab.table_catalog AS database_name, tab.table_schema AS schema_name, tab.table_name, ...
0
votes
1answer
79 views

Grant SELECT on all tables in Redshift

I am trying to assign SELECT privilege to a group in Redshift. So I created a group and a user in that group: CREATE GROUP data_viewers; CREATE USER <user> PASSWORD '<password>' IN GROUP ...
0
votes
1answer
46 views

How do I find the day of week of a date-time field in postgres?

How do I find the day of week of a date-time field? I'm trying to extract the the day of the week from a column in a sql query in postgres. While SELECT EXTRACT(DOW FROM '2011-07-07') works, the ...
1
vote
1answer
23 views

Why does my PostgreSQL query cost so much when I tack on an additional group-by?

I need to extract two fields from a table. Here's the query with just one of the fields: set schema 'data'; explain (analyze, verbose) select count(example9), example9, ...
1
vote
1answer
39 views

postgresql: PANIC: cannot operate with inconsistent data

I'm trying to setup a replica using repmgr: repmgr -D /var/lib/postgresql/9.3/main -p 5432 -U repmgr -R postgres \ --verbose standby clone psql.master.example.com repmgr --verbose standby register ...
1
vote
1answer
38 views

Slow Query Postgres 9.2

I've got the following query: SELECT j.id, concat(c.company, ' ', c.name_first, ' ', c.name_last) AS client, c.email AS client_email, concat(bc....
1
vote
1answer
52 views

pg_dump fails to create a backup when running from System User in Windows Task Scheduler

I am trying to run a pg_dump through a scheduled task in windows. I have two batch files. One creates the task. The other one runs the pg_dump. Even though the pg_dump works with the current user with ...
0
votes
0answers
22 views

Hibernate not using the max id while inserting record

I have a table with over 54000 entries. I had imported this data from a CSV file. When I use hibernate and try to insert a new row into this table, its not picking up the max id adding one and ...
5
votes
4answers
228 views

How can I represent discrete ages in a relational database?

I am using PostgreSQL to store data on a Person. I need to store whether each Person is capable of teaching a Child of each age year, from 0-17. The ages are discrete values, and a Person can have any ...
6
votes
2answers
149 views

Creating relationships between tables that where not specified in the given UML diagram

Good evening! I'm working on designing my very first actual database from the following UML class diagram (in French unfortunately): I'm at the point of creating the relational sketch of it which ...
1
vote
1answer
56 views

Group permissions in postgreSQL not inheriting to table level

I am moving to a group role from a lot of individual users and have one table that needs to have permissions SELECT, INSERT only. Lets say I have: user1 user2 newgroup Both of the users are in ...
3
votes
3answers
65 views

Create unique sequence per set of rows sharing the same foreign key value

In my system, I want each user to have an own id sequence for his articles. So, I have created a database that has a table that depicts a correspondence between users and their articles. Here is the ...
1
vote
1answer
40 views

Strategies for reducing data to summaries within a table over time?

I have a large data set where large numbers of entries differ only by timestamp. In the short term it's beneficial to maintain individual entries so that we can correlate by time for individual data ...
1
vote
1answer
38 views

Set a default value for a jsonb property in PostgreSQL

Let's say that I have a jsonb column with documents like: { "lead": "The lead", "video": "An URL to the video" } In some cases I also need to store the name of a picture that's uploaded to ...
3
votes
2answers
121 views

Two names for a column

I have a column named foo in a table. I have constructed queries in scripts, which use this name. I would now like to rename the column in the table to bar. This will break the scripts (there are ...
0
votes
1answer
31 views

Is a partition a relation?

Is a partition a relation in its own right, or is a partitioned table a single relation? Specifically, do we need to increase max_fsm_relations when we split tables up into loads of partitions?
0
votes
0answers
22 views

Pg_partman giving problem in partman.check_name_length function

I am using Pg_partman inpostgres to partition table using id. I am using the Partition Per 10 ID Values Starting With Empty Table Example given in the below link https://github.com/keithf4/...
0
votes
0answers
9 views

Can a bucardo source be a read-only database?

I'd like to use a wall-shipped read-only database as a source for bucardo replication. Of course, bucardo triggers have been set up in the master. But as the slave is read-only, bucardo will not be ...
3
votes
1answer
27 views

enforcing data integrity for sequential relations

These are my tables: create table trips ( trip_id serial primary key, trip_nm text ); create table trip_segments ( segment_id serial primary key, departure_ts timestamp with time zone, -- ...
2
votes
1answer
44 views

Best practice for working with materialized views in Postgres

As background, I work with many materialized views which are based on PostGIS spatial queries, some of which take days to refresh (these views are infrequently refreshed whenever the underlying ...
1
vote
1answer
57 views

Alter default privileges for role

I have database called Blackacre and two roles who have access to it: johnrole and janerole. janerole has been granted ALL privileges and johnrole has only been granted the SELECT privilege. Problem ...
1
vote
0answers
53 views

Replication of PostgreSQL cluster from Datacenter to Office with write access

Some information about the cluster: Version: postgres 9.5 Size: /postgres/data$ du -hs . 854G OS: Ubuntu 14.04 LTS Storage: Raid10 SSD's I have a master-slave PostgreSQL 9.5 ...