PostgreSQL version 9.3

learn more… | top users | synonyms (2)

0
votes
1answer
8 views

Can we use subquery in GRANT statement in postgres

I want to grant select privilege on few selected tables. Can I use sub-query in GRANT statement???? I have tried the following query: GRANT SELECT ON TABLE (SELECT array_to_string( ...
0
votes
1answer
9 views

postgis installation gone awry

[cross-posted from stack ove On a Ubuntu 14.04 staging server a MySQL connection protocol had to be installed for full-text searching for a separate application. This led to installing, uninstalling ...
0
votes
1answer
36 views

Getting records for yesterday, but per hour

I am currently getting all data for yesterday from my database but I want to get data for each hour. This is my query: select camera_id, count(*) as snapshot_count from snapshots where ...
5
votes
1answer
57 views

dumping database with “compressed data is corrupt” errors

I'm using pg_dump to dump a large (396 GB) PostgreSQL database: pg_dump --clean --create mydatabase After running for a day, a statement fails with ERROR: compressed data is corrupt and pg_dump ...
0
votes
0answers
59 views

Postgres, promoting slave to master issue

We had the following setup in place db01 -> Master Postgres 9.3 db02 -> Slave Postgres 9.3 Master data got corrupted (logically) and as soon as it was identified we shutdown the server. Dev team ...
0
votes
0answers
8 views

Variable type to store result of SELECT returning multiple rows in PostgreSQL

I'm writing a function in PostgreSQL 9.3 and I want to store the names of the columns of a table into a variable, but I'm struggling to find the correct data type: CREATE OR REPLACE FUNCTION ...
2
votes
2answers
66 views

Retrieving changed rows only from a table with 10^7 rows

I have a table with about 300 columns and about 107 rows and I have to retrieve changed rows only, ordered by time (not distinct, but changed). The result set may be limited to 100 rows as well. I've ...
4
votes
1answer
106 views

PostgreSQL seems to create inefficient plans in simple conditional joins

Consider these two queries: SELECT t1.id, * FROM t1 INNER JOIN t2 ON t1.id = t2.id where t1.id > -9223372036513411363; And: SELECT t1.id, * FROM t1 INNER JOIN t2 ON ...
2
votes
1answer
59 views

PostgreSQL not using index during count(*)

I have a COUNT(*) query in PostgreSQL that runs often, and looks like: SELECT COUNT(*) FROM customer WHERE source_id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); This query ...
1
vote
1answer
12 views

getting records for yesterday day starting till ending PostgreSQL

Currently my application is running over 2 dbs one is snapshotDB one is evercamDB. In snapshotDB we are saving records now it want to retrieve them , currently am using this query select ...
3
votes
1answer
26 views

Specifying a username while running initdb causes error in log on start of PostgreSQL process

I have been forced to use a different default username for PostgreSQL. Before you ask: no, this is not something I can avoid. It's dumb, I know. Let's move on: In order to do this in an existing Cent ...
0
votes
0answers
39 views

date/time field value out of range: “21/1/2016” [duplicate]

My PostgreSQL database version is PostgreSQL 9.3.10 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit In both databases, datestyle is set to"ISO, DMY". ATTEMPT 1 ...
0
votes
0answers
87 views

errors install and start postgresql-9.5

UPDATE Why I run "sudo apt-get purge postgresql-9.4 postgresql-client-9.5 postgresql-client-common postgresql-common" and everything is OK??? My ubuntu is 12.04.1. Does it matter with this? I ...
0
votes
1answer
41 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 ...
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, ...
1
vote
1answer
32 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 ...
2
votes
1answer
56 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, ...
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
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 ...
0
votes
0answers
12 views

empty tablespace in postgres [duplicate]

With SELECT spcname FROM pg_tablespace; one can list tablespaces in Postgres. However, other than using du, how can one determine whether a tablespace is empty or not? If one tries to drop a ...
1
vote
1answer
35 views

Postgres Can't Add Foreign Key Constraint

I have a table with about 220 million records :( and I need to add a foreign key constraint. My command looks something like this: ALTER TABLE events ADD CONSTRAINT events_visitor_id_fkey FOREIGN ...
1
vote
0answers
26 views

Is log shipping good for periodic synchronization?

I have Postgresql 9.3 server on both my laptop and my desktop at home. I keep identical data on both system. Sometimes I work on the database on my laptop while other times I work on the database on ...
4
votes
1answer
46 views

Deadlock best practices

We are running Postgres 9.3, and we have occasional deadlock issues. Currently someone notices and will manually kill off the processes. Is there a best practice in dealing with these when they ...
2
votes
0answers
54 views

Postgresql Streaming Replication Error: WAL segment removed

I want to set up PostgreSQL streaming replication, but get the following error: FATAL: could not receive data from WAL stream: ERROR: requested WAL segment 00000001000000000000006A has already ...
1
vote
0answers
53 views

How to fix postgres stuck in recovery mode?

I have Jira and Confluence installed in a server. We didn't have any free disk space one day, and these services didn't started correctly, so after deleting some files we now have some free space ...
4
votes
2answers
89 views

Optimize a query with small LIMIT, predicate on one column and order by another

I'm using Postgres 9.3.4 and I have 4 queries that have very similar inputs but have vastly different response times: Query #1 EXPLAIN ANALYZE SELECT posts.* FROM posts WHERE posts.source_id IN ...
1
vote
1answer
22 views

postgres user cannot access location of new data directory

I moved my postgresql 9.3 data directory to a different drive, however, my postgres user cannot seem to access that new drive despite my best efforts. I am running on ubuntu 14.04 LTS x64. So I ...
1
vote
0answers
18 views

How to speedup pg_dump big database

I've got big database (about 900GB), and when I migrate it to new server dump speed is not more than 2MB/s (very slow). Link between servers is 10Gb/s. The database contain 20 tables with different ...
1
vote
0answers
8 views

xmlforest() omits any fields that are null entirely, instead of creating an “empty” element

I'm know I can use an empty string, but I don't want to lose the null functionality in the database. In some cases null is appropriate and I can't use empty strings. Other than a empty string, how ...
3
votes
1answer
102 views

pg_stat_statements not found even with "shared_preload_libraries = 'pg_stat_statements'

I have followed the instructions given below: http://www.postgresql.org/docs/9.3/static/pgstatstatements.html ... to the effect of adding the following lines: # postgresql.conf ...
2
votes
0answers
43 views

Output from `pg_dump --schema-only` has inconsistent order

I'm trying to compare schemas between 2 (identical) databases using pg_dump --schema-only in PostgreSQL 9.3.9, but the diff of the output shows the ordering is inconsistent for two triggers: ...
0
votes
0answers
28 views

Postgres Issue :could not locate a valid checkpoint record

Below is the error coming at Slave. i want to make it writable how can i do that postgres.conf at slave wal_buffers = '-1' wal_keep_segments = 48 wal_level = 'hot_standby' work_mem = '18MB' ...
0
votes
1answer
33 views

Postgres develops server doesn't listen error spontaniously

I have been running Postgres 9.3 continuously for days on a windows 7 machine with no problems. This morning I came in to see that Postgres, and every application using my postgres database had ...
2
votes
1answer
61 views

Get max url from PostgreSQL statement

I have a very complex query which generates a view in PostgreSQL. Now the query returns duplicated rows, well almost duplicated: one field, the "url" column is different. Now we still want to group ...
0
votes
1answer
49 views

function json_populate_record(…, text) does not exist

I went by the example from the docu which went fine: select * from json_populate_record(null::x, '{"a":1,"b":2}') But my self-constructed JSON simplified similar to this did not work :-( -- ...
0
votes
1answer
29 views

pgAgent doesn't run on another database than “postgres”

I run a postgreSQL 9.3.3 database and I want to do some automatic Tasks with pgAgent, but it doesn't run on another database than "postgres" db. What can I do to run pgAgent on another db ? thanks ! ...
3
votes
1answer
121 views

Bad performance with select on view if check for 'is null'

I have two quite simple tables, and a view to join them on bigint fields: CREATE TABLE foo.ao ( id serial NOT NULL, ao_id bigint NOT NULL, ao_plz text, ao_community text, ao_street text, ...
0
votes
0answers
46 views

Which pgpool “mode” for high availability & failover on Postgresql 9.3

I'm in the process of designing a HA setup for a web API & application that uses Postgresql 9.3. To satisfy availability & resiliency, we require: failover to a secondary database instance ...
0
votes
0answers
30 views

Slow count using postgresql?

I have a query that is executed frequently with a few of the same conditions EXPLAIN ANALYZE SELECT COUNT(*) FROM "comments" WHERE "comments"."published" = 't' AND "comments"."user_id" = 15 AND ...
1
vote
1answer
65 views

Is it possible to obtain number of prepared statements a connection holds?

I have a heavy loaded application that holds connections persistently (it creates them on start and never releases). During the lifetime it creates and (re)uses prepared statements, which are stored ...
2
votes
0answers
115 views

PostgreSQL 9.3 running on Linux - need to authenticate vs. Windows Active Directory

Database server is Ubuntu Linux 3.13.0-68-generic Database is PostgreSQL 9.3.10 LDAP set up according to https://cdc.iseage.org/tutorial-pam-ldap-authentication-active-directory-debianubuntu/ ...
1
vote
0answers
27 views

Enterprisedb, PostgreSQL cast to date

How to cast '2015-11-13 00:00:00' (text or timestamp) to '2015-11-13'(date) in Enterprisedb (EDB) ? With 4 queries below: 1/ SELECT '2015-11-13 00:00:00'::date ; --> result: "2015-11-13" 2/ ...
0
votes
1answer
25 views

Postgresql delete query never ends

I am having an issue which I can't resolve. delete from bb_gamelist_league this operation is taking too long. There are 276224 rows in that column. Delete is performed without any WHERE ...
0
votes
1answer
25 views

Proper Postgresql vacuuming practices

Some tables are very dynamic in terms of additions and subtraction of records. The application (rails 4.2) deletes a large number of records daily. However, the size of the database to the OS - or ...
1
vote
1answer
36 views

Selecting latest row for user grouped by day help

Hoping someone can help me here as I can't quite wrap my head around the best way to do this. Im trying to SUM() some numbers from a JSON block, which I have working just fine, how ever there could ...
0
votes
0answers
14 views

PostgreSQL - Error: duplicate key value violates unique constraint [duplicate]

I try to insert a record into following table: CREATE TABLE web_structure( id serial NOT NULL, label character varying(255), name character varying(255) NOT NULL, frompage integer, topage ...
0
votes
0answers
19 views

Efficient import of 1 million SQL files in Postgresql

I have a huge problem. I have 1 million SQL files varying in size from 9KB to 3MB that I need to import into one table very quickly. The files represent hundreds of billions of rows. Is there a ...
0
votes
1answer
16 views

Can I make something similar to a makefile for psql?

Basically I have a handful of .sql files that I regularly modify in structure that need to be run in a certain order: CREATE.sql, INSERT.sql, PLPSGSQL.sql, TEST.sql, DROP.sql Since every structural ...
1
vote
1answer
40 views

Postgres 9.3 copy data from another table with relation [closed]

Hi I have two tables in my database which is related, which is forms and qa_forms. forms ->id ->name -address -phone -calldatetime and then ` qa_forms ->id ->forms_id ->name ...
0
votes
1answer
86 views

PostgreSQL error moving data directory to home folder

I have a problem with the moving of my data directory of PostgreSQL. I found many different ways, but none worked. The most sensible way for me was: Stop PostgreSQL Copy data from old folder to new ...