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
2answers
20 views

PostgreSQL return word after matching first character

I would like to return the words beginning with ':' from 'select :barns, :fowl, :cows from farm' using regexp_matches. So far I have: select regexp_matches('select :barns, :fowl, :cows from farm', ...
0
votes
0answers
19 views

I want to how to setup point intime recovery in postgres [closed]

What are the steps for doing point in time recovery frist of all i worked on the database and many changes morning to evening ,but i dont want to afternoon session what am i doing ,by using point ...
0
votes
1answer
38 views

Setting shared_buffers over 320 MB prevents Postgres from restarting

I'm running Postgres 8.1 on a CentOS 5 system with 4 GB of RAM. Whenever I set shared_buffers above 320 MB, it won't run. I've checked SHMMAX and it's at 4294967295 which is the max allowed for a ...
1
vote
0answers
17 views

PostgreSQL: native library learn the filesystem path that was used to load it?

From the _PG_init of a dynamic library that postgres has loaded (either because of a function declaration referring to it, or just LOAD pathname; in SQL), is there any call I can make, not ...
3
votes
1answer
16 views

PostgreSQL: restrict a GUC variable to only be set in proconfig?

If a C extension defines a custom GUC variable, is there any combination of GUC "context","source","flags", etc., that can be used to make the system only allow it to be set from the SET (i.e. ...
4
votes
3answers
52 views

Do not reject entire statement when deleting rows in batch

I have a table who's purpose is to store the application's various images. It is defined this way : CREATE TABLE images ( id lo NOT NULL, name character varying(1024) NOT NULL, type character ...
2
votes
1answer
22 views

postgresql on windows won't install with data and executables on different disks

I am trying to install postgresql 9.4.4 on a windows 2008 rc2 machine that has 2 HDs. The first HD is, in theory, used only for executables/code/etc while the second one, being faster, should be used ...
1
vote
1answer
51 views

DB design for employee working hours constraints [closed]

I have a simple employee schedule database (I use PostgreSQL): employees: - id - name - email shifts: - start - stop - employee_id Now there is need to apply constraint for working hours. ...
0
votes
1answer
22 views

PostgreSQL visibility of records changes from other transaction inside the current one

I have a table "tst" which has a "status" column using which we process records in that table. Once the records are processed we set the status to 'Y'; #\d tst Table "core.tst" ...
0
votes
1answer
45 views

What is the best way to take backup for Remote DB Server

I am building a software, which will supports multiple database like MySQL, Oracle and PostgreSQL. These databases are installed on remote machines. i wanted to use java technology in a non-database ...
-2
votes
1answer
31 views

PostgreSQL - what do tms and mt mean in a SELECT query? [closed]

I'm trying to see if I can optimize the following query which was written by my predecessor: SELECT tms.*, 0 as kyori , (power( (139.745069 - ...
3
votes
1answer
46 views

COUNT number of column values with INNER JOIN [closed]

I'm new to PostgreSQL and I am making a Report. This is my SQL Fiddle: http://sqlfiddle.com/#!15/6ce465/5 So basically I have two tables, responses and questions. The structure is responses ...
2
votes
1answer
40 views

Using an UPDATE trigger to populate Eastings and Northings in PostgreSQL

I am wondering if it is at all possible to create trigger that populates the X and Y of a created point into 2 separate fields called 'easting' and 'northing'? It is an update trigger on a table ...
5
votes
1answer
182 views

Rolling sum / count / average over date interval

In a database of transactions spanning 1,000s of entities over 18 months, I would like to run a query to group every possible 30-day period by entity_id with a SUM of their transaction amounts and ...
1
vote
2answers
306 views

How to best store a timestamp in PostgreSQL?

I'm working on a PostgreSQL DB design and I am wondering how best to store timestamps. Assumptions Users in different timezones will use the database for all CRUD functions. I have looked at 2 ...
2
votes
1answer
41 views

How to validate column while creating Table?

Need to validate the column while creating the tables in postgres , An example before developer create table We are in need to validate the Audit columns, Example : create table tab_1 ( a integer, b ...
1
vote
1answer
30 views

Procedure to read from crontab like table and populate another one periodically

Postgres 9.3 Debian 7 I'm working on a mobile game project (poker like) where an admin user can register a recurrent tournament. As it's recurrent, I modeled it crontab like as follows. ...
2
votes
0answers
29 views

pg_dump with ssl certificates

I would like to run the pg_dump command from a remote host off my database server that only allows fully verified certificate based connections. How should I go about doing this? The man pages for 9.1 ...
1
vote
2answers
59 views

Is it recommended to install extensions into pg_catalog schema?

Since objects in pg_catalog schema are implicitly in the search_path (docs), would it be recommended to install extensions in that schema?
0
votes
1answer
21 views

Postgres or MapReduce to Match Reciprocal Needle Pairs from a Stack of Needles?

I have a Postgres (latest version) table with about a million lines (a_lat, a_lon, b_lat, b_lon) that each have about a dozen criteria. These lines go together in reciprocal pairs (A - B, B - A), ...
0
votes
0answers
10 views

Updating the details of an ACCESS-2003 database on completion of a PostgreSQL UPDATE trigger

I am currently stuck and looking for some further guidance. I have a database in access, which on UPDATE (trigger function) will take the data inputted into the PostgreSQL table in QGIS, and update ...
1
vote
2answers
38 views

Proper usage of Group by in Inner Join

EDIT I updated my question with a SQL Fiddle Sample http://sqlfiddle.com/#!15/8d88b/1 I'm currently making a report from a database records but I don't know how my query should look like, first of ...
2
votes
0answers
24 views

PostgreSQL/PostGIS: Query seems inordinately time-consuming

I'm doing what I would consider a pretty straightforward query on two tables that aren't huge (~626k records in one; ~47k records in the other). Both tables have GIST indices on their spatial ...
2
votes
1answer
86 views

Avoid joining to the same table multiple times

I have two tables: CREATE TABLE one ( id int4 primary key, p_id int4, k_id int4, c_id int4 ); CREATE TABLE two( id int4 primary key, p_id int4, k_id int4, t_id int4, pos int4 ); Table ...
-1
votes
0answers
30 views

How would I make this query run faster in postgres [closed]

Query: with customer_total_return as (select wr_returning_customer_sk as ctr_customer_sk ,ca_state as ctr_state, sum(wr_return_amt) as ctr_total_return from web_returns ...
3
votes
1answer
94 views

How to store time series data

I have what I believe is a time series data set (please correct me if I'm wrong) that has a bunch of associated values. An example would be modeling a car and tracking its various attributes during a ...
0
votes
2answers
33 views

PostgreSQL, merge join results

I have 2 tables with common columns and would like to know if it's possible to request this 2 tables by merging the results. Table "job" : parent_id, target_id, start_date, end_date, jobposition_id ...
3
votes
2answers
74 views

How to log custom messages from inside a PostgreSQL transaction?

I have a software that generates transactions and executes them. I would like to asynchronously inspect about the transaction progress in term of the simple proportion of queries executed over total ...
4
votes
2answers
73 views

Grouping by sequential relationships with Postgres

This is quite similar to this question about continuous ranges, and this question about grouping by sequential numbers, but differs in that the sequences are not numeric. Given the following ...
3
votes
2answers
132 views

Filter and append data to row

My query and my data set (copied from sqlfiddle): CREATE TABLE one ( id int4 primary key, p_id int4, k_id int4 ); CREATE TABLE two( id int4 primary key, p_id int4, k_id int4, ...
1
vote
0answers
60 views

Having problems trying to back up a Postgres database from AWS RDS

I am trying to backup a Postgres database from RDS and I am getting this error message. pg_dump: [archiver (db)] query failed: SSL error: unexpected message pg_dump: [archiver (db)] query ...
3
votes
1answer
55 views

Finding optimal indices, different query competing indices

My schema: create TABLE "logs" ( "id" serial not null default nextval('logs_id_seq'::regclass), "request" varchar(1024), "token" varchar(512) default NULL, "was_batch_request" bool ...
2
votes
2answers
115 views

How to cast to int array in Postgresql?

I would like to cast from ARGV[] which is text to int array in PostgreSQL where I marked the pseudocode by TODO in the code. Code in PostgreSQL 9.4.3 on x86_64-unknown-linux-gnu, compiled by gcc ...
0
votes
0answers
31 views

Merging data from two slightly different datasets

A bit of backstory: we used to have a single Postgresql db that we had to duplicate when we opened a new office. So at that moment there were two indipendent dbs with perfectly identical data. Over ...
2
votes
1answer
29 views

How to Choose Between VALUES and SELECT for INSERT?

This answer raised the question for me how to choose between VALUES and SELECT in such a function . Using PostgreSQL 9.4.3 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit: ...
3
votes
3answers
205 views

Do I want an index if all I care to query is field not null

In SQL, do all the common considerations about indexes apply if everything I'll ever want to query (in the where condition) is when a field is not null? Is there a special configuration of the index ...
0
votes
2answers
29 views

Get min and max row from table

From a table with the columns: id(pk), type_id, book_id, title_id, page_id, lines(int4), created_at(date) How can I select the row with min(lines) and max(lines) for (type_id, book_id, title_id, ...
1
vote
1answer
36 views

Challenges with Key with Gaps?

I had a mistake with a trigger which resulted in errors in PostgreSQL 9.4.3 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit. Each time during the error, the primary key ...
0
votes
1answer
45 views

PostgreSQL window functions very slow on big table

I have a PostgreSQL table constructed as device_id | point | dt_edit ----------+-----------+---------- 100 | geometry | timestamp 101 | geometry | timestamp 100 | geometry | ...
2
votes
1answer
19 views

Update postgres row where condition is from another table

I want to update a password field from a given value that exists from another table. user_info: -------------------------------------------- | user_login | password | ...
5
votes
0answers
128 views

Why is my PostgreSQL ORDER BY case-insensitive?

I have Postgres 9.4.4 running on Debian and I get the following ORDER BY behavior: veure_test=# show LC_COLLATE; lc_collate ------------- en_US.UTF-8 (1 row) veure_test=# SELECT ...
1
vote
0answers
33 views

PostgreSQL suddenly using all my disk space

Today I fired up my linux mint via my virtual computer (host is windows 8), left for 30 minutes, and when I was back, I got an error saying I was out of disk space. Yesterday I had about 20 free GB ...
0
votes
1answer
41 views

Does PostgreSQL benefit from more cores or faster cores for READ heavy applications? [closed]

I have been trying to figure out how to go about configuration of a PostgreSQL instance that will have 64GB ram (which is far larger than the database) and if I should opt for more cores or faster ...
2
votes
1answer
28 views

How to allow users to run a function, but not access objects the function is accessing

I have a PL/PgSQL stored procedure that performs various operations on tables (SELECT, UPDATE, INSERT, TRUNCATE). I want users to be able to run the stored procedure, but not themselves perform those ...
0
votes
1answer
38 views

What is the proper setup for PG user for web application

We have a web app that detects if the DB does not exist and creates it. Users like it, but my thought is that such user has too much privileges. I would optimally propose to change the DB creation ...
1
vote
1answer
120 views

SELECT in trigger function in two tables

My table and trigger in PostgreSQL 9.4.3 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit: CREATE TABLE measurements ( measurement_id SERIAL PRIMARY KEY NOT NULL, ...
2
votes
0answers
43 views

Recovering data from postgresql xlog

I lost a lot of data in my postgresql database and do not have a dump file to restore backup from, but I heard that in /var/lib/postgresql/9.4/main there are pg_xlog and pg_clog and that those ...
0
votes
0answers
24 views

Multiple table relationship for different scenarios!

We have the following heirarchy in our platform; Package is comprised of Products, Products is comprised of Services and Services are comprised of SKUs. The relationship between them is many-to-many ...
3
votes
1answer
51 views

Automatic aging-out (deletion) of old records in Postgres

Does Postgres have any features to support aging-out old records? I want to use Postgres for logging, as a sort of queue, where records (log events) older than two weeks are automatically deleted.
3
votes
2answers
65 views

how do you prevent dead rows from hanging around in postgresql?

I have production and staging RDS instances on amazon, and staging's data is a direct copy of production so both instances have duplicate data. Doing a EXPLAIN ANALYZE SELECT * from my_table WHERE ...