All versions of PostgreSQL. Add a version-specific tag like postgresql-9.4 if that context is important.

learn more… | top users | synonyms (1)

3
votes
1answer
70 views

Why is my tsv index not being used?

I'm trying to get the postgres full-text-search facility functional. I have two tables, one I created just for testing, and the actual one I want to be able to search: Test Table: webarchive=# \d ...
0
votes
1answer
263 views

Install specific older version of postgresql centos

I need to rebuild a production system with same version of installed packages. It's a Centos 5.11 and it was using this repo http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-centos-8.3-6.noarch.rpm to ...
0
votes
0answers
310 views

pgpoolAdmin for pgpool-II 3.4 : superuser: unknown (Connection error)

I cannot start/stop/reload my nodes through pgpoolAdmin and it says "superuser: unknown" even though I'm logged with the postgres account. What could be the cause? pgpool.conf is identical to another ...
-1
votes
1answer
123 views

Cannot connect Eclipse to PostgreSQL [closed]

I see this error message when I'm trying to connect to PostgreSQL from Eclipse. org.postgresql.util.PSQLException: FATAL: password authentication failed for user "postgres" at ...
1
vote
1answer
47 views

ORDER BY text doesn't use my index?!

currently this query doesn't use a index even after I created one: EXPLAIN ANALYZE SELECT * FROM customer_list WHERE rating = 3 ORDER BY name ASC LIMIT 20 ; ...
3
votes
2answers
236 views

Can I find all JSON scalars in PostgreSQL 9.3?

We are using Postgres 9.3 and making use of the JSON column which was new to that version. Version 9.4 added a LOT of utility functions for handling JSON, as well as the new JSONB column. You can see ...
3
votes
1answer
139 views

How to log all SQL queries for a single connection or user or client host?

Is there a way to log all SQL queries in Postgres 9.3.9 for a single connection or user or client host? In other words, I want log_statement = all but only for a certain username or client hostname ...
17
votes
6answers
14k views

PostgreSQL: Force data into memory

Is there a systematic way to force PostgreSQL to load a specific table into memory, or at least read it from disk so that it will be cached by the system?
2
votes
1answer
852 views

Implementing json_object_agg() in Postgres 9.3

I feel like I need the json_object_agg() function of Postgres 9.4 but I will not be able to upgrade from 9.3 right now. Is there a way to do what I want in 9.3? Here's my scenario. I have a table ...
3
votes
2answers
6k views

Postgresql - Recovery using recovery.conf

I am trying to recover a database using recovery.conf file for making point-in-time copy. On recovery.conf file, I added a recovery target time as below. recovery_target_time = '2011-06-16 04:10:00 ...
1
vote
2answers
5k views

How to CREATE TABLE … LIKE without the NOT NULL Constraints?

I'm trying recreate a table's structure inside a function by using some dynamic SQL. EXECUTE 'CREATE TABLE ' || my_table_name || '_bk' || ' (like ' || _my_table_name || ')'; That will be ...
2
votes
0answers
114 views

Old records disappearing after upgrade from 9.4.1 to 9.4.4

I recently upgraded from 9.4.1 to 9.4.4. Since then millions of rows have disappeared from several tables containing historical data. The severity of data loss seems to be directly proportional to ...
1
vote
1answer
62 views

Interpreting Decision Time (DT) in temporal databases

Could anyone give me an insight for the need to model decision time in temporal databases and specifically how and why decision time differs from valid time and transaction time? What would be the ...
44
votes
3answers
111k views

Granting access to all tables for a user

I'm a new to Postgres and trying to migrate our MySQL databases over. In MySQL I can grant SELECT, UPDATE, INSERT, DELETE privileges on a low privileged user and enable those grants to apply to all ...
2
votes
2answers
146 views

Tables names in a supertype/subtype schema [closed]

I have 3 types of users in my app. The users share some common attributes, but they also have quite a bit of stuff that pertains uniquely to each user type. I have a person table that contains limited ...
1
vote
0answers
19 views

Why can I not alias a column in a view? [duplicate]

I am trying to create a view that provides all quarter starts from a date dimension. Here it is: CREATE OR REPLACE VIEW quarter_starts AS SELECT min(day_number_in_epoch) AS day_num FROM ...
0
votes
1answer
395 views

difference between pg_dump command's --column-insert and --attribute-insert

Background: I'm trying to create a dump file that only contains the data in my database. I would like it to create the data with the INSERT command. In reading the manual, ...
545
votes
7answers
970k views

How do I list all databases and tables using psql?

I am trying to learn PostgreSQL administration and have started learning how to use the psql command line tool. When I log in with psql --username=postgres, how do I list all databases and tables? I ...
0
votes
0answers
296 views

How to include all sequences in pg_dump/pg_restore?

(Also posted to http://stackoverflow.com/q/32832486/398670) I have a PostgreSQL 9.4.4 database on my development server that contains test data that I want to dump and then restore to my production ...
1
vote
1answer
72 views

UPDATE id table on the columns with the same name

I may be a newbie question but I don't know how to resolve this. I have a table like: name | id | value A 1286487 1286333 B 1286489 1286403 C 1286495 1286455 C ...
4
votes
1answer
10k views

Declare variable of table type in PL/pgSQL

I am wondering if there is a way to declare a variable of type table in PL/pgSQL to hold query results? For instance how can I express something like: q1 = select * from foo; q2 = select * from bar; ...
1
vote
0answers
37 views

Postgres stream WAL segment removed

We have a master server and replication server running Postgres 9.3.6 Streaming was going slow due to a secondary failover router. It was running behind but still working. I got a communication ...
0
votes
0answers
292 views

pg_restore not restoring sequences

I'm transferring all of the databases on my old postgres server to a new server. To do this I'm using pg_dumpall and then pg_restore. However, it appears that no sequences have been dumped. This is ...
0
votes
1answer
18 views

PostgreSQL SQL: updating summaries

I'm trying to optimize a query like: UPDATE master SET count = (SELECT COUNT(*) FROM detail WHERE detail.master_id=master.id) Where the master table is large, so running this results in a huge ...
2
votes
2answers
408 views

Postgres slave max_connections = master's max_connections?

I am using binary replication for Postgres. Is it true that the max_connections has to be the SAME for both the master and slave in postgresql.conf? Can they be different?
5
votes
1answer
629 views

PostgreSQL could not fork autovacuum worker process: Cannot allocate memory

Running into some issues every few days with postgres crashing and entering recovery mode. The logs from postgres look like so ... Lots of this for 5-10minutes 2015-09-24 10:07:27 GMT LOG: could ...
3
votes
2answers
2k views

How to create and populate a PostgreSQL table from CSV automatically?

I am new to database management and we are using PostgreSQL. All I need to do is to migrate CSV files (corresponding to around 200 tables) to our database. Manually creating tables for every CSVfile ...
0
votes
1answer
963 views

could not open log file “/var/log/postgresql-2015-05-24_181212.log”: Permission denied

I installed postgresql from source on Ubuntu 14.04 (I also installed from repositories too before, I just want to get a feel for both of them right now, as I will heavily rely on this database). So ...
8
votes
1answer
219 views

PostgreSQL bytea vs smallint[]

I'm looking to import large (100Mb -- 1 GB) multi-channel time-series data into a PostgreSQL database. The data comes from EDF format files that chunks the data into "records" or "epochs" of typically ...
3
votes
1answer
142 views

RDS raising unwanted PostGIS NOTICEs

I have an Amazon RDS instance that is producing unwanted NOTICEs. I have never seen this behaviour before. mydb=> select current_setting('client_min_messages'); current_setting ...
1
vote
0answers
62 views

How can we plan for a High Availability/Disaster Recovery setup in Postgresql 9.3? [closed]

I am working for mission critical project. We are planning for High Availability. At any point of time irrespective of the failure (network, hw, or db) one db server should be available for the ...
1
vote
1answer
933 views

How to install Slony for 64-bit PostgreSQL 9.3 on Windows?

I have installed 64-bit version of PostgreSQL 9.3.5 from EnterpriseDB installer. Now I want to install Slony-I through Application Stack Builder, but it offers only 32-bit version of Slony, ...
1
vote
2answers
127 views

Retrieve additional columns in recursive CTE

This works as far as getting the amount of children a "thread" has but now I can't seem to get it to pull parent row columns. Parent rows have parent_id is null, trees can be any level deep. I manage ...
4
votes
2answers
203 views

Get the last 5 distinct values for each ID

I'm working with PostgreSQL 9.4. I have a table that contains the following entries: id | postcode | date_created ---+----------+----------------- 14 | al2 2qp | 2015-09-23 14:46:57 14 | al2 ...
2
votes
1answer
54 views

Dealing with corruption: file-level backup vs. pg_basebackup

The wiki on corruption recommends immediately taking a file-level backup of your database by stopping the postmaster and using tar, but I was under the impression that using pg_basebackup was a better ...
4
votes
2answers
202 views

Use column values in ORDER BY and LIMIT clauses

I have this table in a Postgres 9.3 database: I need to use the content of columns order and limit to sort and filter this table. The table will be sorted by column first_name. The final result ...
2
votes
1answer
37 views

Excluding rows by lots of ids

I need to exclude some rows that the user has already seen. Currently I am doing this by simply comparing the ids that the user has seen to the row's ids by running this query (there are also other ...
1
vote
1answer
50 views

Left join not working with sub-query

I've got table of scores where each entry corresponds to a particular (student, subject) pair. CREATE TABLE score ( id serial PRIMARY KEY, value integer NOT NULL, subject_id integer NOT NULL, ...
3
votes
1answer
147 views

Prevent explicit insert into serial columns

I want to prevent explicit inserts into serial columns. I have come up to the following trigger: drop table test_table; create table test_table( id bigserial primary key, foobar text ); create or ...
3
votes
2answers
241 views

Use composite type to create new table

In ORDBMS databases I have seen that complex types can be used: create type name as( ...) And I can references those types when creating a new table, like: create table example (row_name ...
3
votes
1answer
55 views

Replacing a large object in PostgreSQL

What should one do when one wishes to replace a large object with a new large object. An example would be to update an uploaded file with a new version. One way would presumably be to create a new ...
20
votes
3answers
18k views

upgrading from postgres 9.1 to 9.3 on ubuntu server

I have my production server(ubuntu 13.10) running with postgresql 9.1. I want to use few features of 9.3, hence want to upgrade. Could someone help me with upgrading from 9.1 to 9.3 so that there is ...
68
votes
6answers
8k views

Do stored procedures prevent SQL injection?

Is it true that stored procedures prevent SQL injection attacks against PostgreSQL databases? I did a little research and found out that SQL Server, Oracle and MySQL are not safe against SQL injection ...
-3
votes
1answer
43 views

How can postgresql copy tables to another name

Now is Setempber I have 3 tables , t1,t2,t3 When it comes to October, I want to create another 3 tables named t1_09,t2_09,t3_09 which stored data from t1,t2,t3 (copy t1,t2,t3 to t1_09,t2_09,t3_09) ...
2
votes
3answers
120 views

Performance of rare SELECT vs. frequent INSERT in timeseries data

I have a simple timeseries table movement_history ( data_id serial, item_id character varying (8), event_time timestamp without timezone, location_id character varying (7), ...
11
votes
3answers
345 views

Constraint to enforce “at least one” or “exactly one” in a database

Say we have users and each user can have multiple email addresses CREATE TABLE emails ( user_id integer, email_address text, is_active boolean ) Some sample rows user_id | ...
34
votes
3answers
31k views

Idiomatic way to implement UPSERT in PostgreSQL

I've read about different UPSERT implementations in PostgreSQL, but all of these solutions are relatively old or relatively exotic (using writeable CTE, for example). And I'm just not a psql expert ...
7
votes
0answers
129 views

How to do Statistics in Partial Indexes of PostgreSQL efficiently? [duplicate]

This answer motivated think again my following tables but I am still uncertain how to store variables/results from data analysis for quick selection in post-processing. If stored, I think it is well ...
1
vote
3answers
179 views

Get count estimates from pg_class.reltuples for given conditions

Is it possible to query the reltuples column for a given table with additional conditions like table.name LIKE 'hello%'? Currently on my bigger tables the SELECT count(*) query takes long and I ...
2
votes
1answer
84 views

Query result in a daily date from a date range selection Postgres 9.3

I need to make a report that will output a result in a daily row result based on the datarange selected. Example: Table: sales ->id ->type ->gross ->created_at ->updated_at For ...