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
8 views

postgresql: accept subdomain wildcards?

I want to accept all db connections from servers with domain mydomain.com so that all subdomains like tiger.mydomain.com, venus.mydomain.com will have access to the postgresql server. I've read that ...
2
votes
0answers
13 views

Rollback on \include error in psql

I'm trying to execute an sql script file in a single transation. The file contains includes for some other scripts which in my example create some tables. It looks like this: \include ...
0
votes
0answers
11 views

pgAdmin-III - Option to load a favorite automatically when opening query window

pgAdmin-III - Query window option Does pgAdmin-III has any option to load a default favorite file automatically when opening new query window? This would be much useful to have commit/rollback ...
-5
votes
1answer
54 views

how to Write a SQL Statement to display EmployeeID from Table1 and EmployeeName from Table2 a [on hold]

how to Write a SQL Statement to display Claim Number, EmployeeID from Table1 and EmployeeName from Table2 above. Write a SQL Statement to display all the Information from Table1 and Table2 for ...
0
votes
0answers
22 views

PostgreSQL indexing table on multiple columns

I have a table that holds half hour metering values in a compact form on a daily basis. The table has a structure as described below: day: timestamp without time zone, // describes a day ...
0
votes
0answers
25 views

Which replication technique to use?

I would like use Postgresql 9.3, i'm looking for a replication solution permitting this use cases. there's 2 servers both can write data, so they must be synchronized with some frequency if the DSL ...
1
vote
0answers
8 views

export data to xml by the use of query to xml then importing it using xpath

i have use QUERY_TO_XML function in order to export data to xml , after that i want to export this data. this data might contain reserved chars in the xml tags like "' & ..." ex electrical ' ...
0
votes
0answers
20 views

Concurrent SELECT and UPDATE in multiprocessing python

I have to randomly match about 20 million rows in two tables without using the same row twice using PostgreSQL 9.3.5. Both tables have the following structure CREATE TABLE de_sim_points_end ( -- ...
0
votes
1answer
19 views

Postgres Table Ownership

I'm new to PostgreSQL and I'm trying to change the table owner for a bunch of tables. I was able to change the ownership by logging in a the postgres user and executing alter table owner to user1, but ...
0
votes
2answers
50 views

How to compare an Oracle database with a Postgresql database?

We are currently migrating an Oracle database 10gR2 to a Postgresql database 9.3. Thanks to Hibernate, all tables can be recreated seamlessly. However, the Oracle database is huge. We are going to ...
0
votes
0answers
21 views

What minimum RAM should the server have for a Django application with Postgresql server?

I have a Django application. The database is Postgresql with 8GB size. We are also using Nginx with gunicorn. Will a 4GB server be enough for good performance ( like on Digital Ocean) ? I was under ...
0
votes
1answer
25 views

Refresh materalized view incrementally in PostgreSQL

Is it possible to refresh a materialized view incrementally in PostgreSQL i.e. only for the data that is new or has changed? Consider this table & materialized view: CREATE TABLE graph ( ...
1
vote
1answer
32 views

What does the Postgres <-> operator do?

I was reading through the Postgres documentation on materialized views and in one example they use the following: SELECT word FROM words ORDER BY word <-> 'caterpiler' LIMIT 10; I tried to ...
1
vote
2answers
34 views

How to create a temporary table using VALUES in PostgreSQL

I am learning PostgreSQL and trying to figure out how to create a temporary table or a WITH declaration that can be used in place of regular table, for debugging purposes. I looked at the ...
0
votes
0answers
12 views

Possible to get log file with only statements sent to Postgres from my app (and not from psql prompt)?

I'm using an ORM in my app and would like to see all statements sent to Postgres so that I can figure out exactly what the ORM is doing. In the Postgres config file I added log_statement = 'all' to ...
0
votes
0answers
11 views

What should be the ideal network configuration for a Postgresql Streanming Replication and PgPool HA setup

I have the following configuration using Pgpool, Postgresql with streaming replication. Pgpool is used for load balancing and automatic failover. .-----. .--------. | | ...
0
votes
1answer
18 views

How can I aggregate multiple results from another table using something like BOOL_AND?

I'm using PostgreSQL as my database. CREATE TABLE users ( id SERIAL NOT NULL, name TEXT NOT NULL, PRIMARY KEY (id), UNIQUE (name) ); CREATE TABLE groups ( id ...
0
votes
2answers
37 views

insert inserted id to another table

Here's the scenario: create table a ( id serial primary key, val text ); create table b ( id serial primary key, a_id integer references a(id) ); create rule a_inserted as on insert to a do ...
1
vote
0answers
41 views

Are CTEs multithreaded?

Here and here seem to suggest that they are, but I've also been told (source unlocatable) that a multi-row single-statement insert will only use one thread for all writing, that to multithread it, the ...
1
vote
1answer
30 views

Performance of single vs multiple column unique constraint

I'm using PostgreSQL 9.3. I want to understand if I have an option to make a constraint unique across the entire table vs. unique across a subset of the table (i.e. by using 2 columns in the unique ...
1
vote
1answer
22 views

Table-based custom type does not verify check constraints

Is there any way for a table-based custom type to obey the table check constraints, other than creating my own type based on the table? Assume the following table that serves as a source for the ...
2
votes
1answer
58 views

Monitoring the Postgres query parser

As I understand it, when you send a query to Postgres like: SELECT id FROM table1 WHERE name = $1; Postgres will create a query plan. The plan will be cached for the same query in the same ...
0
votes
0answers
24 views

Get columns from NEW when execute update on postgresql [closed]

I need know if determide fields are into result of update execution, e.g. IF NEW.niveope is null THEN _new_nivope := 0; ELSE _new_nivope := NEW.nivope; END IF; When I execute: EXPLAIN ...
0
votes
1answer
27 views

How can I create a bool column for a view based on the result of a statement?

I'm using PostgreSQL as my database. CREATE TABLE groups ( id SERIAL NOT NULL, name TEXT NOT NULL, PRIMARY KEY (id), UNIQUE (name) ); CREATE TABLE users ( id ...
2
votes
1answer
38 views

Get products of category plus all child categories till leaf nodes

We have a hierarchy which looks this: Now the problem is that most products are only connected with 1 category, which is most of the time the lowest level. I am trying to get ALL products below a ...
0
votes
0answers
23 views

Are A or D series VMs better for deploying PostgreSQL on Azure?

In Azure there are VMs that have local storage either as spinning disk (A-series) or SSD (D-series). Considering this space is wiped on reboot... Is there a benefit to choosing the SSD option for ...
1
vote
1answer
24 views

How do I use pg_dump and pg_restore to move a large database to another machine?

I'm a bit unclear on how to use the pg_dump/pg_restore duo to move a large-ish database. Here is the command I use to dump the database (the host and username are taken from environmental variables): ...
2
votes
1answer
65 views

Recursive CTE to find unique slug

I have an article table where I want the slug to be unique. CREATE TABLE article ( title char(50) NOT NULL, slug char(50) NOT NULL ); When the user enters a title e.g. News on Apple, I want ...
-5
votes
0answers
23 views

We are trying to set up a database to be able to read and write messages on a website [closed]

We are trying to set up a database to be able to read and write messages on a website but cannot figure out how to make a function for a button to take the information from the webpage text box and ...
3
votes
1answer
37 views

Possible reasons for irregularly high query execution time?

The above is a graph showing the average response times per second (including error bars) for an experiment where I simulate 30 clients which are all invoking the same query multiple times. I ran ...
0
votes
0answers
16 views

PostgreSQL: PANIC: heap2_redo: unknown op code 32

I was doing migrations while the server was still accessing the slave DB. I have a master / slave setup. After I restarted the server, I realized I couldn't connect to the SLAVE anymore. I went into ...
0
votes
1answer
35 views

Postgresql csv to db translate foreign keys

I'm trying to import data from a csv to a postgresql database. the db table looks like this: CREATE TABLE texts( text_id serial PRIMARY KEY, topic_id integer REFERENCES topics, format_id integer ...
0
votes
0answers
22 views

ETL - Moving data from Postgres/Oracle to a TripleStore (RDF)

I'm looking for pointers on how to handle an ETL process that I have to implement for my organization. I know how to query SQL database but i'm not SQL DB specialist. I work more in the sphere of the ...
0
votes
0answers
39 views

Unique index on columns which are allowed to be NULL

I'm having a little problem right now, we use this table in our database: CREATE TABLE offer ( offer_id serial PRIMARY KEY , product_id int NOT NULL REFERENCES product , price_old ...
1
vote
2answers
41 views

Group by range of years

I've got a big table (~9M rows) and want to group the rows on a field containing the year. So far that's pretty easy: // greatly simplified: SELECT count(*), year FROM dataset GROUP BY year ORDER BY ...
5
votes
2answers
137 views

Managing CTE execution order under uncertainty

I am writing a large, multi-step CTE for performance reasons. In one query, data must be moved from one table to another, but the quantity of rows moved is uncertain and could be zero. In a ...
2
votes
2answers
28 views

Get all (non repeated) distribuidores with their paises given a producto_solicitud

I have this schema: And as title says I need to get all records from fabricante_distribuidor by given producto_solicitud.id value. I'm doing in this way: SELECT ...
2
votes
0answers
60 views

Prepared statement overhead

I am using libpqxx to communicate with a PostgreSQL 9.3 server. For multiple table inserts, if they are split into individual prepared statements, they cost approximately 2ms each. If they are all ...
0
votes
1answer
24 views

Initialize, Start Server and Create Database in Single Script

I am writing a provision script for a dev environment with the following: sudo su - postgres <<EOF cd ~/data pg_ctl -D . initdb pg_ctl -D . -l run.log start createdb mydb pg_ctl -D . stop EOF ...
1
vote
1answer
30 views

What are the side-effects of disabling nested loops in postgres?

A query of multiple joins spends a lot of time on nested loops. I disabled the nested loops and the query ran much faster. However, I have been told that nested loops might give me wrong results by ...
3
votes
2answers
28 views

How can I determine if a table exists in the current search_path with PLPGSQL?

I'm writing a setup script for an application that's an addon for another application, so I want to check if the tables for the other application exist. If not, I want to give the user a useful ...
5
votes
1answer
69 views

Sort by number of related rows in referencing table

Let there be two tables: Users id [pk] | name --------+--------- 1 | Alice 2 | Bob 3 | Charlie 4 | Dan Emails id | user_id | email ----+---------+------- 1 | 1 ...
0
votes
0answers
13 views

How to do a pgdump with strings encoded?

When I perform a dump with pg_dump tool, with a "flat" sql format, pg_dump create a regular sql file but the restoration with pg_restore fails because the strings are not escaped. For example, single ...
1
vote
1answer
41 views

Migrate SQL Server binary datadump to postgresql

I just got a very big dataset (+/-55GB) in a binary SQL Server format. Is there an easy way to import this file into a Postgresql Server? I found some converter-programs, but they 'only' convert ...
0
votes
0answers
12 views

Backing up AWS database to an on premise server

I have 2 questions - 1) Are there tools, AWS provided or otherwise, which can continuously backup a cloud-based database (Postgresql RDS) to an on-premise server ? 2) I want to do this, so that I ...
2
votes
1answer
45 views

What is the etymology of the hstore datatype in postgres?

Where did the datatype get its name? Hash store?
1
vote
2answers
45 views

Add function parameter to SQL query WHERE clause

I have a web application in java and it uses a query. I don't want to write the query into Java, so I made a function: CREATE OR REPLACE FUNCTION testFunc(inputs text) RETURNS TABLE(...) AS $$ ...
0
votes
0answers
36 views

Translate psql meta-command to SQL

How can I translate a psql meta-command (like \dt or \ds) to the equivalent SQL query? I found some of the translations here. But it would be nice to have a command to do it automatically.
0
votes
0answers
33 views

Getting wrong results from fulltext search in PostgreSQL

This is the query which I am running. The keyword "exhausted" is present only in one of the rows but I am getting all 3 rows. How to avoid the rows where the keyword is not present? DDL: CREATE ...
0
votes
1answer
16 views

create insertion rule on view returning id

I have a table private.products and a view public.products representing that table. And I want to create entries in private.products while inserting into view, it all works right, except that I also ...