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
1answer
14 views

postgres finding child tables for particular table

I want to find all child tables corresponding to particular parent table. SELECT * FROM information_schema.table_constraints tc right JOIN information_schema.constraint_column_usage ccu ...
0
votes
0answers
13 views

Are my queries to Postgresql hot spare actually being handled there?

I have master and minion database servers each running Arch Linux, with the latter acting as a hot spare database with replication. I wrote a service that is supposed to check whether the replication ...
1
vote
2answers
49 views

Postgres Index a query with MAX and groupBy

Is there any way to index the following query? SELECT run_id, MAX ( frame ) , MAX ( time ) FROM run.frames_stat GROUP BY run_id; I've tried creating sorted (non-composite) indexes on frame and ...
0
votes
0answers
9 views

Problem with Postgres installation on MacOSX - psql does not work [duplicate]

I'm currently trying to install Postgres (using the installation package from http://postgresapp.com) on OSX Mavericks (10.9), i.e. through downloading, unpacking, and dragging the Postgres app into ...
0
votes
1answer
22 views

Postgres installation on MacOSX - problem with psql

I'm currently trying to install Postgres (using the installation package from http://postgresapp.com), i.e. downloading, unpacking, dragging the app into the Applications folder, launching the app. So ...
-3
votes
1answer
54 views

How match a numeric column with a varchar parameter? [closed]

external_id in my source table is of varchar(255) data type I need to convert it to a numeric(20) to do a lookup on target table where card_id (contains external_id's) is of numeric(20) data type. I ...
0
votes
1answer
34 views

Delete index while query is running, is it possible?

I am currently importing Wikipedia pagelinks in my postgres database, and it takes forever (three days and still running). Is it possible to drop the primary key index while the inserts are still ...
0
votes
1answer
20 views

Is there any way to get the optimization time in PostgreSQL? [duplicate]

I'd like to see how long it takes to optimize a query. Does PostgreSQL support this feature?
3
votes
1answer
53 views

How can I implement a sequence for each foreign key value?

In a PostgreSQL (9.3) database, I have a one-to-many relationship between Accounts and Customers, so within the Customers table, I have a globally-unique id for the primary key of each Customer, plus ...
0
votes
1answer
17 views

How to convert time without time zone to timestamp without time zone in PostgreSQL?

I received this error when trying to alter a column of type time to type timestamp: PG::CannotCoerce: ERROR: cannot cast type time without time zone to timestamp without time zone It's not ...
0
votes
1answer
19 views

How to update records of one table with the values of another one (PostgreSQL)

I have a table t1 with columns account_id and user_id, and another table users with columns id and account_id. I want to populate t1.account_id with the values of users.account_id. For instance ...
0
votes
1answer
11 views

How to set weights on a Postgres TSVECTOR column?

Currently, I'm using Postgres 9.3.5 for full-text search but I don't want to set weight or convert to tsvector on the fly (a lot of articles suggest that, and that just seems like a terrible idea to ...
0
votes
0answers
18 views

Efficient Trigger updating in Postgresql

So I have a big table that often needs specific columns updated for a large number of rows. So right now I have it set up so that there is a 'staging' table that has the update-able columns. Then upon ...
0
votes
1answer
47 views

Best query to exclude existing friends from query

I have a User table / id_user / username / .. friends table (pair AB and BA): / friend_of / friend_to and a friend_request table (used for pending friend requests) / id_req/ sent_from / sent_to ...
1
vote
0answers
12 views

noobie to streaming replication in postgres 9.2

I've been asked to reverse engineer an app that uses postgresql in the back end. I can see that there is some database replica tion going on... based on my reading, I *think it's called streaming ...
0
votes
0answers
19 views

Tuning PostgreSQL for minimum reliability and bulk updates

I'm using PostgreSQL to host some data that comes from external source, the normal operation of the database is read-only with periodic updates. Updates though are kinda huge e.g. in a 50 million row ...
2
votes
1answer
29 views

Is it possible to backup and restore a materialized view with it's data?

I have some hard to compute materialized views, which I want to be able to backup and restore using the actual stored data, and not by recomputing. Is it possible in PostgreSQL 9.4? (the alternative ...
0
votes
0answers
18 views

How do I alter my role to be a superuser?

I'm working my way through the steps in this slide to configure Postgresql & PostGIS. I configured my user role as directed on this slide. Note, the new role should not be a superuser. That ...
0
votes
2answers
35 views

WHERE clause converting INT to DATETIME

Looking for advice on how to match two differing column types: I have two tables: RT-A and DA-B. Under both tables there is a column named DeliveryDate, but the individual tables use differing ...
1
vote
1answer
26 views

Finding the current prices for n Fuelstations at a certain point in time

I have a Table where price information is stored in with approx 13 million rows stored in a PostgreSQL 9.5 database. CREATE TABLE public.de_tt_priceinfo ( id integer NOT NULL DEFAULT ...
2
votes
1answer
58 views

How to speed up select distinct?

I have a simple select distinct on some time series data: SELECT DISTINCT user_id FROM events WHERE project_id = 6 AND time > '2015-01-11 8:00:00' AND time < '2015-02-10 8:00:00'; And it ...
0
votes
1answer
23 views

Good encryption performance

I'm converting a sql server database to postgresql 9.4. I'm stuck on something that is really really slow. I use copy to bulk insert 200 files of 5000 lines each into 200 tables (one file per table). ...
0
votes
1answer
17 views

Compare only day / month / year portion of a timestamp field

I am creating a view for a certain table, where rows have timestamp fields (planned_ts). The view needs to be sorted according to these timestamps, but since the application is only interested by the ...
0
votes
0answers
11 views

Postgresql : Table historisation

I would like to do a script that gather data from an API everyday. (8000 lines/days) So for each object would like a object1 table for the data of the day. And a object1_hist for archived data. ...
0
votes
1answer
13 views

Returning setof derived from for loop in plpgsql

I have the below function. It is intended to loop through every schema and return all user IDs from a table in that schema. The schemas have the format: users[0-100]. $body$ declare r varchar; ...
0
votes
0answers
20 views

How to create counter for table column (not id) which reset to 1 every month?

I suppose that I need to do something like this: ALTER SEQUENCE product_id_seq RESTART WITH 1 But I want to do this automatically every month.
0
votes
0answers
21 views

Delete data from related Tables with condition

I have Table a (id, id_d); --fk contraints = on delete cascade Table b (id, language_code); Table c (id_a, id_b); --fk contraints = on delete cascade Table d (id); I want to delete an entry from ...
0
votes
0answers
16 views

psql: how to turn off context messages at raise notice

If I use raise notice, I get context messages at each execution. Can I turn them off and just get the NOTICE? NOTICE: d = [2,1] ,tn: (1,2,"{NULL,NULL}","{{-1,4},{-1,-1}}",1) CONTEXT: SQL ...
0
votes
0answers
10 views

How to block messages from Londiste?

This question is part postgres and part londiste. I have successfully upgraded PostgreSQL from 9.1 to 9.3 using Londiste. However, in the PostgreSQL 9.3 log, I am still getting some messages related ...
0
votes
1answer
16 views

Postgresql 9.1 PITR file system base backup - do I need to stop database?

I am preparing for a migration of a big database to another server and plan to use WAL archiving and Point-In-Time-Recovery to minimize downtime. After reading the documentation I learned I have to do ...
0
votes
1answer
25 views

Get statistics of slow running queries

My database application runs many different queries. I have set log_min_duration_statement to 1000. But queries logged there are not always slow, most times they just take a few ms. Is it possible to ...
0
votes
0answers
28 views

Reducing the size of a PostgreSQL Database, utilizing a process other than full VACUUM

We have a Postgres 8.4 installation which hosts both our Defect tracking and Code management (Surround) systems. We are looking at converting and migrating Surround to MSSQL on another server. Our ...
1
vote
1answer
40 views

Join and count boolean columns by logical OR

There are two tables: user_table and user_schedule. Each user has four schedule rows (one for each 6 hour period per day) with one column for every workday. The desired result is to count the number ...
0
votes
1answer
20 views

Grant access to all tables of a database

I recently wanted to share regular access rights with one user of a server and I realized that a simple CREATE USER and GRANT ALL ON DATABASE commands didn't let him run a simple SELECT on the data. ...
1
vote
1answer
50 views

PostgreSQL isn't using indices in FULL OUTER JOIN

I have these tables I'd like to do a FULL OUTER JOIN between. They both have an index on (ts_minute, user_id, campaign_id, host_id) (which matches the join condition). In the following query, if I ...
2
votes
1answer
30 views

INSERT multiple values via join

I have three tables, representing two entities and a connection relationship. Each of the entity relations has an artificial surrogate key used for foreign key constraints in place of natural keys. ...
2
votes
1answer
49 views

How do completely empty columns in a large table affect performance?

I have 400 million rows in a Postgres db, and the table has 18 columns: id serial NOT NULL, a integer, b integer, c integer, d smallint, e timestamp without time zone, f smallint, g timestamp without ...
0
votes
0answers
17 views

How to check if an IP is contained in a list of networks in PostgreSQL?

I have two tables: The first one contains a list of networks and IP-addresses with their IDs and a User-ID, the second one contains log entries with a source address. A given user must only be able to ...
2
votes
1answer
20 views

How can I add a numeric version_id column to an existing table?

I have a table in a postgres db with rows versioned with a timestamp that I'd like to add a numeric version_id column to. eg. existing: ID VERSION_DATE -- ----------------------- A 2015-02-05 ...
0
votes
0answers
16 views

Postgres shared_buffers utilization

Hi is it possible to show how much of the shared_buffers postgres is using or how can i know it is too small?
1
vote
1answer
63 views

Reuse SELECT query by adding results in array?

I have written a PostgreSQL function, which returns a specific order of products. Now I would like, not only to show, but to put the results of the first SELECT query to an array as well, so I can ...
-2
votes
0answers
14 views

error no server supplied when importing sql file

I am trying to import an SQL file which have size about 24Mb, but it's failings. No Server Supplied What could be the problem?
1
vote
2answers
46 views

Reset the sequence of a serial PK with dynamic SQL

How can I dynamically reference a sequence name (as below) using a combination of strings and DECLARE variables? Is the code below proper or is there another method of doing this? My goal is to do ...
0
votes
1answer
27 views

PostgreSQL function thinks table reference exists when it does not

So I run this query: SELECT f_copy_tbl('parts','parts1'); ...while working on code based off of this answer and I get this error message: ERROR: relation "parts1" already exists pgAdmin III ...
0
votes
0answers
14 views

PostgreSQL plpgsql math increment a DECLARE to fix table sequence [duplicate]

The answer to this question will help me post a full (hopefully) working answer to my earlier question about replicating tables and their primary key. I'm new to plpgsql so the context of this ...
1
vote
1answer
63 views

Multi table GROUP BY query optimisation

Currently I have a multi table/column GROUP BY query which is pretty slow. Below is the tables schema used by the query: report Table ...
1
vote
1answer
24 views

Rename the constraint of a possibly referenced primary key in PostgreSQL

Is it safe to use this command just like that, even though the table might be referenced from other tables as foreign key? ALTER INDEX foo_pkey RENAME TO pk__foo__id; I have just tried it and it ...
1
vote
0answers
18 views

Combining date and date/time ranges in PostgreSQL

In a PostgreSQL table, I'd like to store events which have a range telling when the event is happening. However, some events span whole days (i.e., the user does not care about time), while others ...
1
vote
0answers
29 views

Implementing a consistent mailbox

I am trying to implement something like a mailbox for short messages between users. I am using Postgresql 9.4.1 with SQLAlchemy (Python3). There is a table of users: users = Table('users',metadata, ...
0
votes
0answers
14 views

Should I partition table by time or project_id, or both?

I have a table of event data that is getting slightly large. It's ~10 million records. I want to partition the table to help speed things up. I almost always restrict the query by both the time and ...