Re: distinguish update from insert (on conflict)

2019-05-21 Thread Justin Pryzby
On Tue, May 21, 2019 at 06:57:36PM -0700, Adrian Klaver wrote: > On 5/21/19 6:34 PM, Justin Pryzby wrote: > >Is it still impossible to distinguish whether a row was inserted vs updated ? > > You will need to be more specific. Sorry, I mean with UPSERT / "INSERT .. ON CONFLICT DO UPDATE", is it po

Re: distinguish update from insert (on conflict)

2019-05-21 Thread Adrian Klaver
On 5/21/19 6:34 PM, Justin Pryzby wrote: Is it still impossible to distinguish whether a row was inserted vs updated ? You will need to be more specific. On a hunch, see transition relation info here: https://www.postgresql.org/docs/10/sql-createtrigger.html The latest I can see is here: ht

distinguish update from insert (on conflict)

2019-05-21 Thread Justin Pryzby
Is it still impossible to distinguish whether a row was inserted vs updated ? The latest I can see is here: https://wiki.postgresql.org/wiki/UPSERT#RETURNING_behavior ..but I'm hopeful that the 4 year old wiki page is out of date. Justin

Re: Loading table with indexed jsonb field is stalling

2019-05-21 Thread Will Hartung
> On May 20, 2019, at 5:31 PM, Tom Lane wrote: > > Well, you're the only one who's seen this problem, and none of the > rest of us have any idea how to reproduce it. So if you want something > to get done in a timely fashion, it's up to you to show us a test case. So, we had success. We look

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Jeremy Finzel
On Tue, May 21, 2019 at 12:24 PM Rich Shepard wrote: > On Tue, 21 May 2019, Francisco Olarte wrote: > > > From how you say it, I assume you have some data in your original > > dumps which can relate boths, lets assume it's org_name, but may be an > > org-code. If you do not have it it means you c

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Rich Shepard
On Tue, 21 May 2019, Will Hartung wrote: You can either use a script for the entire process, or, convert the people table to INSERT statements that have a SELECT for the foreign key as part of the insert. INSERT INTO PEOPLE (id, name, org_id) VALUES (1, ‘Bob’, (SELECT org_id FROM org WHERE org_

Re: Re: Re: Refresh Publication takes hours and doesn´t finish

2019-05-21 Thread Tom Lane
=?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= writes: > Em ter, 21 de mai de 2019 às 14:41, Tom Lane escreveu: >> It's a view, not a table, so I don't think you need >> allow_system_table_mods. A quick test here says that being >> superuser is enough to do a CREATE OR REPLACE VIEW on it. > Interesti

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Will Hartung
> On May 21, 2019, at 9:56 AM, Rich Shepard wrote: > > I could insert all new rows into the organizations table, then produce a > list of the org_id and org_name to manually insert the foreign key in the > related people table. Time and effort intense. You can either use a script for the entire

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Ron
On 5/21/19 12:27 PM, Rich Shepard wrote: On Tue, 21 May 2019, Michael Lewis wrote: For each row- Insert into organizations table if the record does not exist, returning ID. Insert into people using that ID. Michael, The org_id will not exist until I run the insert script. Else, load all th

Re: Re: Refresh Publication takes hours and doesn´t finish

2019-05-21 Thread Fabrízio de Royes Mello
Em ter, 21 de mai de 2019 às 14:41, Tom Lane escreveu: > > =?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= writes: > > As I said before to change system catalog you should set > > "allow_system_table_mods=on" and restart PostgreSQL service. > > After that you'll able to recreate the "pg_catalog.pg_publi

Re: Re: Refresh Publication takes hours and doesn´t finish

2019-05-21 Thread Tom Lane
=?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= writes: > As I said before to change system catalog you should set > "allow_system_table_mods=on" and restart PostgreSQL service. > After that you'll able to recreate the "pg_catalog.pg_publication_tables" > system view. (You can use the Tom's suggestion us

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Rich Shepard
On Tue, 21 May 2019, Adrian Klaver wrote: The other way is to create the org_id for each organization ahead of time and put it into the data file. Either way you have create the org_id for the FK relationship, it is just a matter of where and when. Adrian, I had thought of that but overlooked

Re: Refresh Publication takes hours and doesn´t finish

2019-05-21 Thread Fabrízio de Royes Mello
Em ter, 21 de mai de 2019 às 14:17, PegoraroF10 escreveu: > > Restart Postgres means exactly what ? We tried just restart the service but > we tried to refresh publication the old view was used because it took 2hours > and gave us a timeout. > As I said before to change system catalog you should

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Rich Shepard
On Tue, 21 May 2019, Michael Lewis wrote: For each row- Insert into organizations table if the record does not exist, returning ID. Insert into people using that ID. Michael, The org_id will not exist until I run the insert script. Else, load all the data with empty ID column on person tabl

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Adrian Klaver
On 5/21/19 10:22 AM, Rich Shepard wrote: On Tue, 21 May 2019, Adrian Klaver wrote: Well you are not going to know the org_id until the organization table is loaded, which means something like: 1) First run through file load the organizations table. 2) Build a mapping of org_id to organizatio

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Rich Shepard
On Tue, 21 May 2019, Francisco Olarte wrote: From how you say it, I assume you have some data in your original dumps which can relate boths, lets assume it's org_name, but may be an org-code. If you do not have it it means you cannot match people to orgs in your data, all is lost. Francisco,

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Michael Lewis
For each row- Insert into organizations table if the record does not exist, returning ID. Insert into people using that ID. Else, load all the data with empty ID column on person table,then just update the person table afterward and drop the org name column. Perhaps I am missing something.

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Rich Shepard
On Tue, 21 May 2019, Adrian Klaver wrote: Well you are not going to know the org_id until the organization table is loaded, which means something like: 1) First run through file load the organizations table. 2) Build a mapping of org_id to organization. 3) Run through data file again and loa

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Francisco Olarte
Rich: On Tue, May 21, 2019 at 6:56 PM Rich Shepard wrote: > I'm cleaning and formatting a 800-line data file to be inserted into a > database. Some of the input file fields will be inserted into an > 'organizations' table letting postgres assign sequential org_id numbers. > Other fields will be i

Re: Refresh Publication takes hours and doesn´t finish

2019-05-21 Thread PegoraroF10
Restart Postgres means exactly what ? We tried just restart the service but we tried to refresh publication the old view was used because it took 2hours and gave us a timeout. I found some people talking that I need to initdb, but initdb means recreate entirely my database or just reinstall my pos

Re: Re: Refresh Publication takes hours and doesn´t finish

2019-05-21 Thread PegoraroF10
I cannot because we created a replication for ALL TABLES -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html

Re: Bulk inserts into two (related) tables

2019-05-21 Thread Adrian Klaver
On 5/21/19 9:56 AM, Rich Shepard wrote: I'm cleaning and formatting a 800-line data file to be inserted into a database. Some of the input file fields will be inserted into an 'organizations' table letting postgres assign sequential org_id numbers. Other fields will be inserted into a separate 'p

Bulk inserts into two (related) tables

2019-05-21 Thread Rich Shepard
I'm cleaning and formatting a 800-line data file to be inserted into a database. Some of the input file fields will be inserted into an 'organizations' table letting postgres assign sequential org_id numbers. Other fields will be inserted into a separate 'people' table associated with each organiz

Re: PITR based recovery in a primary/standby cluster setup

2019-05-21 Thread Frank Alberto Rodriguez
Hello.I'm not sure which replications issues you have, and I never used Wall-E before, but I get some issues with PotgreSql 10 and Barman. Try starting the primary server at first, when it finish to recovery this should start as primary, if not then go to the postgresql data directory and rename th

Re: no matching entries in passwd file

2019-05-21 Thread Fabio Pardi
Hi Daulat, I believe that the error message is referring to the system user, not the database one. docker exec --help | grep -- -u -u, --user string Username or UID (format: [:]) regards, fabio pardi On 5/21/19 2:42 PM, Daulat Ram wrote: > Hello team, > >   > > I have  databas

no matching entries in passwd file

2019-05-21 Thread Daulat Ram
Hello team, I have database & users created inside the docker but we are getting connection issue while trying to connect to database using user created in postgres. docker exec -it -u test b8e7ejb1e31d bash unable to find user test: no matching entries in passwd file Regards, Daulat

PITR based recovery in a primary/standby cluster setup

2019-05-21 Thread Abhijit Gharami
Hi, We have primary and standby PostgreSQL cluster setup and also we have PITR enabled on it. To improve the recovery time we are thinking of recovering the database to both primary and standby at the same time. These are the steps we are following: 1. Restore the base backup to the both primar