postgresql-10

Return data from subselect used in INSERT in a Common Table Expression

扶醉桌前 提交于 2020-01-15 12:44:52
问题 I am trying to move bytea data from one table to another, updating references in one query. Therefore I would like to return data from the query used for the insert that is not used for the insert. INSERT INTO file_data (data) select image from task_log where image is not null RETURNING id as file_data_id, task_log.id as task_log_id But I get an error for that query: [42P01] ERROR: missing FROM-clause entry for table "task_log" I want to do something like: WITH inserted AS ( INSERT INTO file

How to migrate an existing Postgres Table to partitioned table as transparently as possible?

百般思念 提交于 2020-01-02 03:57:05
问题 I have an existing table in a postgres-DB. For the sake of demonstration, this is how it looks like: create table myTable( forDate date not null, key2 int not null, value int not null, primary key (forDate, key2) ); insert into myTable (forDate, key2, value) values ('2000-01-01', 1, 1), ('2000-01-01', 2, 1), ('2000-01-15', 1, 3), ('2000-03-02', 1, 19), ('2000-03-30', 15, 8), ('2011-12-15', 1, 11); However in contrast to these few values, myTable is actually HUGE and it is growing continuously

Postgresql 10 - Parallel configuration

怎甘沉沦 提交于 2020-01-02 02:34:06
问题 There are 4 configurations to enable the parallel and do the optimization, but the documentation of PostgreSQL doesn't says anything about values or calculation. My questions are: 1- How to calculate the values of max_parallel_workers , max_parallel_workers_per_gather and max_worker_processes ? 2- The work_mem can be calculate on base of connections and memory(RAM), but the work_mem needs to change something if I enable the parallel? My supposition is: if the machine has 8 cores the max

How to partition postgres table using intermediate table

断了今生、忘了曾经 提交于 2019-12-29 02:06:15
问题 I am using postgres 10 db. I am having Customers table consisting of following columns custid (primary key), name, phonenumber, email, dateofbirth, address, city, country, status(boolean) Join_Date(Date) I have million of records in table. I want to partition table based on different months(Jan 2018 one partition, Feb 2018 one partition,..etc) by help of Join_Date and with help of Intermediate table. I also want to write the automated script such that at the end of month the table have to get

How to partition postgres table using intermediate table

☆樱花仙子☆ 提交于 2019-12-29 02:06:10
问题 I am using postgres 10 db. I am having Customers table consisting of following columns custid (primary key), name, phonenumber, email, dateofbirth, address, city, country, status(boolean) Join_Date(Date) I have million of records in table. I want to partition table based on different months(Jan 2018 one partition, Feb 2018 one partition,..etc) by help of Join_Date and with help of Intermediate table. I also want to write the automated script such that at the end of month the table have to get

Using text in pl/pgsql brings empty set of results

痞子三分冷 提交于 2019-12-25 00:53:08
问题 I am new to pl/pgsql and trying to create a dynamic query. What I have now is a basic combination of parameters for testing. When it works properly, I will gradually add more dynamic parts, to create a dynamic, all-in-one query. The problem is that this should work, but instead I see an empty search_creator as Data Output in the pgadmin4. This is the code CREATE FUNCTION search_creator(creator text) RETURNS TABLE(place_id bigint, place_geom geometry, event_name character(200)) AS $$ BEGIN

multiple Postgres clusters (not instances) on 2 machines

ぐ巨炮叔叔 提交于 2019-12-25 00:38:01
问题 I am trying to setup (half way done already) 2 Postgres clusters, say prod and test (not instances) on 2 machines say .114 and .115. One cluster has 2 instances. Each instance runs on each of machines. I am trying to make .114 as primary for test cluster while .115 will work as secondary for it. For prod cluster .115 will work as primary and .114 as secondary. Although it sounds not-good that i have test and prod on same machines but this is what customer needs now. I have already setup test

pg_upgrade with brew mac os 9.6.2 - 10.5

我只是一个虾纸丫 提交于 2019-12-25 00:36:07
问题 I've followed the excellent guide here to upgrade from 9.6.2 to 10.5 on mac os 10.11.6. When I get to the step 6 pg_upgrade -b /usr/local/Cellar/postgresql/9.6.2/bin/ \ -B /usr/local/Cellar/postgresql/10.5/bin/ \ -d /usr/local/Cellar/postgres.old/ \ -D /usr/local/Cellar/postgres.new/ I get this error check for "/usr/local/Cellar/postgresql/9.6.2/bin" failed: No such file or directory even though mv /usr/local/Cellar/postgresql/9.6.2 /usr/local/Cellar/postgres.old ran ok. However when I go to

root.crt not found postgresql

巧了我就是萌 提交于 2019-12-23 03:46:15
问题 I have a postgres docker image that i am using and I am enabling SSL on it. I want it to verify-full because I have a root.crt and want to make sure all the certs that can use SSL are verified. So, in my docker-compose file, i have mounted my server.crt and server.key to /var/ssl and my root.crt to /root/.postgresql. volumes: - ~/server_certs:/var/ssl - ~/root_certs:/root/.postgresql and the error i get is ERROR [2018-07-10 20:28:24,355] org.apache.tomcat.jdbc.pool.ConnectionPool: Unable to