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
4answers
56 views

Insert from Another Table + Removing Duplicate Entries in Postgres

I'm trying to insert data from one PostgreSQL table to another while removing duplicate entries but I'm having some trouble with the code. I have two tables I'm working with: mytesttable, which ...
0
votes
0answers
26 views

Postgres: Arrays instead of intermediate tables for many-to-many relations

I have a PostgreSQL 9.3.7 database scheme representing a directed graph of vertices and edges with some many-to-many relations. I'm only ever interested in getting all vertices that a given vertex ...
3
votes
1answer
151 views

Estimating the size (of the records) and the overhead in Postgres

Consider the following table in Postgres 9.4: CREATE TABLE t ( a1 bigserial, a2 bigint NOT NULL, a3 bigint NOT NULL, a4 integer, a5 timestamp with time zone NOT NULL, a6 timestamp with ...
1
vote
1answer
31 views

Syntax error in postgresql query [closed]

I am trying to migrate a sql query into PostgreSQL. After running the query I get this error: ERROR: syntax error at or near "(" LINE 20: ..._date is null or fcm.effect_end_date>=current_date()) ...
1
vote
1answer
19 views

Accurate PG database size for comparing representations

I have a Java/JDBC program that takes a sample file and imports the data into the database, shredding it across multiple relations. The program does this multiple times for several different ...
1
vote
2answers
27 views

Migrating PostgreSQL files to new server

We have a Win 2008 server that went down because of cpu failure. We were running parts of the Atlassian stack (JIRA, Confluence, Stash, and Bamboo) on it using PostgreSQL as the database. I now have ...
1
vote
1answer
87 views

How to reinstall PostgreSQL over an existing installation

I am trying to upgrade an installer created with NSIS that installs postgresql. It used to install postgresql 8.3 but we want to upgrade the DB to 9.4.4. The old version on of the DB used to be an ...
1
vote
1answer
41 views

Streaming replication and lag when performing VACUUM on master

My streaming replication standby server is showing a delay of a few minutes when vacuuming a large table on the master. What is the reason for the lag, and is there a way to reduce it? Both servers ...
4
votes
0answers
98 views

Why is query thousands of times slower with DESC?

I have a PostgreSQL database (AWS RDS) and ran the following queries in psql: livenet=> EXPLAIN ANALYZE SELECT * FROM outputs ORDER BY height LIMIT 10; Limit (cost=0.57..36.82 rows=10 ...
0
votes
0answers
31 views

Compare two databases

I want to compare two PostgreSQL database dumps. The output of pg_dump is not sorted. This makes tools like diff useless. Background: We update the way we set up a custom database. After our ...
1
vote
1answer
41 views

Pattern matching in PostgreSQL? [closed]

I have a string in which need to extract the date, Example: S01_XXX001_000_min_01_20150526T123440583.arc , S01_XXX001_000_20150526T123440583_min_01.arc based on the pattern like 'Numeric T ...
1
vote
1answer
51 views

Update staging data with production data in Postgresql

I'm using PostgreSQL (version 9.3) on my server and I want to update the data in my staging instance database with the data in my production instance database. Each database is controlled by a ...
1
vote
1answer
51 views

Does VACUUM FULL need ANALYZE

I'd be grateful for some insight into the VACUUM functionality within PostgreSQL 9.3. I read through the documentation and searched around a bit but could not find a definitive answer to this. I'm ...
1
vote
1answer
49 views

To find data in Multiple tables and delete it?

I am using a PostgreSQL server. Suppose I have 200 values in a master table that need to be deleted. There are 9 other tables referencing this master table. The other 9 tables not only reference the ...
2
votes
1answer
50 views

postgresql - how and why indexes are bigger than their tables

I'm using postgresql 9.3 and trying to understand how and why indexes are bigger than their tables. Sample output: database_name | database_size | table_name ...
0
votes
0answers
12 views

How can I create a copy of postgis db from one windows machine to another

I have postgres 9.3 database with postgis extension. I want to create a new database on different computer and import all the tables from the source database. In mssql it would be simple , just ...
0
votes
1answer
28 views

Backup-strategy for redundant data in postgresql-db.

I have a (postgresql-9.3)-table that contains images as a bytea-column as well as several other columns that contain extracted information from these images. (Some feature points, descriptors). These ...
1
vote
1answer
54 views

Is there a way to add a column to a table without affecting performance?

How do you add a column to a table in production without affecting its performance? Or is this impossible? I'm asking about Postgres.
2
votes
2answers
54 views

Calculate number of consecutive years (not gapless)

I have a request that wants to look at numbers of consecutive year buyers. For example, I have a table like this: Order_year, Contact 2015, 123 2014, 123 2013, 123 2011, 123 2010, 123 2015, 234 2014, ...
5
votes
1answer
57 views

Bulk insert M:N relation in PostgreSQL

I need to import data from an old database to a new one, with slightly different structure. For example, in the old database, there is a table recording employees and their supervisors: CREATE TABLE ...
2
votes
3answers
52 views

What schema for different relation from two tables to another?

There are three tables instructors, meeting_points and bookings. Here are the relation I want: 1 instructor has 0, 1 or n meeting_points 1 booking has 1 meeting_point 1 meeting_point can be linked ...
0
votes
2answers
47 views

Approach to take regarding a field that is frequently re-computed

I have a few fields with text data in a main table which is processed in a certain way to produce a processed version of that piece of text. Now, the way in which this text is processed is expected ...
0
votes
0answers
26 views

Replicating table level PostgreSQL 64bit windows

I need to replicate some tables on PostgreSQL 64bit for Windows (master -> slaves replication model) and I can't find any tool that can achieve that. Slony-I work very well for PostgreSQL 32bit for ...
2
votes
1answer
43 views

How do I prevent my query from needlessly generating rows it'll throw away later?

I have the following query: SELECT stream_points.time AS point_time, stream_points.value AS point_value, stream_predictions.value AS prediction_value, ...
2
votes
1answer
29 views

Querying on multiple joined rows

I have a table called visits that is structured like so: +----+--------------+-------------+ | id | name | visitor_id | |----+--------------+-------------+ | 1 | event1 | 1 ...
-1
votes
1answer
34 views

How to setup path to access psql from command line in Mac [closed]

psql does not work even path was set .bash_profile. Path was set export PATH=/Library/PostgreSQL/9.4/bin:$PATH in .bash_profile.
0
votes
1answer
35 views

Postgres lose xlog

I have 2 instances master-salve postgres run on AWS, the xlog folder is on ephemeral disk. The master instance was down, so I lose the xlog folder, Now, i'm trying to start up the master again and ...
3
votes
3answers
44 views

PostgreSQL GRANT ALL on mutliple tables using LIKE

I have more than 100 tables named public.test_* How can I easily GRANT ALL access to the user test to all that tables at once? I tried with: GRANT ALL ON TABLE public.test_* TO test; But it is ...
0
votes
1answer
27 views

Postgres INNER JOIN same table failing on CartoDB

I have a table with data which looks like this +----+------+-------+ | cp | year | count | +----+------+-------+ | 1 | 2000 | 10000 | | 1 | 2001 | 9000 | | 1 | 2002 | 9500 | | 2 | 2000 | 8000 ...
0
votes
0answers
34 views

User with Read Only access on a particular schema- PostgreSQL

I wanted to know if I can make a read only user usr1 on schema sch1 in database db1. In addition, I want that this user not to have any access to anything else in this database (not even read access ...
0
votes
0answers
51 views

PostgreSQL query taking a long time

I have a query that is taking hours to run. There is a large table to parse, is there any way to optimise this? with VehData as ( SELECT * from dblink('host=databasesrv port=1234 ...
1
vote
1answer
40 views

Count number of duplicate rows, sort from most to least (statistic) [closed]

I'm trying to make statistic of top-10 most visited URL. I have one simple table. For each URL visit, one row added with that URL as content. Most visited URL has the most number of duplicate. I've ...
1
vote
1answer
113 views

Syntax error using preparedstatements with postgresql

I have a Java application connecting to a PostgreSQL database. Using straightforward code like: ps = con.prepareStatement(sql); if (dataTypes != null && dataTypes.size() ...
1
vote
0answers
45 views

compound index not being used on simple query

I'm running this query, and it seems to be doing a table scan , rather than using the relevant index.. select count(*) from pages where charity_id=447 and provider_id=1 this is the explain: ...
0
votes
0answers
20 views

PostgreSQL 9.3 - Move table to tablespace - Slow?

I need a help with moving table to a different tablespace. I have a really large table that is not queried much often so I've decided to move it from tablespace on SSD to tablespace on HDD and save ...
1
vote
0answers
35 views

PostgreSQL GUI Tools with Git repository integration [closed]

I'm currently evaluating PostgreSQL GUI tools that have following capabilities: Query Editor GIT Repository Integration for version control Change script generation for deployment between the GIT ...
1
vote
1answer
25 views

How to model state change timeline

I've got an app where users can place orders for recurring delivery of a particular service. The orders table has columns service_id and state, where service_id links to the service the user has ...
1
vote
1answer
66 views

Why isn't Postgres doing an index-only scan?

I am using Postgres 9.4. This is my table: id | integer | not null default nextval('frontend_prescription_id_seq'::regclass) presentation_code | character varying(15) ...
1
vote
1answer
38 views

generate new column from another table column, treating nulls are unique

I have a table that looks like the following: |device_id | login_id | ----------------------- | 1 | NULL | | 2 | A | | 3 | A | | 4 ...
2
votes
1answer
69 views

Best index for similarity function

So I have this table with 6.2 millions records and I have to perform search queries with similarity for one for the column. The queries can be: SELECT "lca_test".* FROM "lca_test" WHERE ...
1
vote
1answer
32 views

Moving postresql 9.1 database - live

This question has probably been asked and answered before, and if so, I would appreciate if that could be pointed out to me. I have googled this point quite a bit, but I want to be very sure as to ...
2
votes
2answers
37 views

Setting shared_buffers in postgresql.conf does not seem to take effect

We're on CentOS release 6.6, PostgreSQL version 8.4.20. (Yes, this is not bleeding edge.) In postgresql.conf, we have: shared_buffers = 4096MB kernel shm values are set nice and high: [root@green ...
0
votes
1answer
45 views

RDS Postgres Peformance

I have recently set up a new RDS instance to test out working with a AWS postgres instance vs a heroku postgres instance. What I've found is that when I load an instance of 1000 entries in RDS its ...
0
votes
2answers
51 views

Can I Show Multiple “WHERE” Filtered Results In A Single Query/Output Table?

I am using Postgres 9.2.4 on Red Hat 6. Tables --------------------------------------- | Table 1 | --------------------------------------- | WorkflowID | DataSet | ...
0
votes
1answer
63 views

Problem with UNION ALL

I have to process 200 points (lat, long) to calculate the minor distance of same object (street in this case). So, I made a simple query to obtain 1 result, and replicate the same to the other 199. ...
0
votes
0answers
45 views

How to check/know the highest run queries

I would like to gather statistics on the highest run queries in my database. For that I need to know how I can track queries so I can create views or materialized views to cache the results of the ...
-2
votes
1answer
65 views

Permission Denied on a database created by the same user

I run this command: psql --username=openerp --dbname=sf_template_20150608111121 --no-password \ --command="update pg_database set datallowconn = false \ where datname = ...
0
votes
1answer
27 views

Postgres DB user permission

I'm logged in as a user in postgres with PgAdmin tool in Linux connecting remotely but I don't think the user has enough rights. I'm a MySQL experienced user but not so much in PostGres. When I select ...
1
vote
1answer
37 views

Using the value of a JSON object that is stored in a PostgreSQL JSON array

I have a table that looks like this (simplified): Jobs ------------------------------- ID | Details ------------------------------- 1 | { 'tasks': [] } 2 | { 'tasks': [{'id': '1', 'due_on': ...
0
votes
1answer
50 views

the cache hit rate using pg_statio_user_tables

I read from this blog that a small 20% of the data in your database is getting the vast 80% of reads. That means a small portion of the data in the database is frequented. Hence, you want to ensure ...