Re: Order by not working

2021-02-16 Thread Laurenz Albe
On Tue, 2021-02-16 at 16:11 -0600, Ron wrote: > SQL is only intuitive to people who've done programming... :) SQL is quite counter-intuitive to people who have only done procedural programming. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com

Re: delete old cluster after pg_upgrade with -k option

2021-02-16 Thread Laurenz Albe
On Wed, 2021-02-17 at 11:39 +0530, Atul Kumar wrote: > I have upgrade the postgres cluster from 9.5 to 9.6 using pg_upgarde > utility with -k option. > > Now I just wanted to be confirmed that is it safe to run > delete_old_cluster.sh file as we have used -k option that must created > hard links

delete old cluster after pg_upgrade with -k option

2021-02-16 Thread Atul Kumar
Hi, I have upgrade the postgres cluster from 9.5 to 9.6 using pg_upgarde utility with -k option. Now I just wanted to be confirmed that is it safe to run delete_old_cluster.sh file as we have used -k option that must created hard links with old cluster. Suggestions are welcome.

Proposed Update to Japanese Translation of Code of Conduct Policy

2021-02-16 Thread Stacey Haysler
The PostgreSQL Community Code of Conduct Committee has received a draft of the Japanese translation of the Code of Conduct Policy updated August 18, 2020 for review. The English version of the Policy is at: https://www.postgresql.org/about/policies/coc/ The patch was created by: Tatsuo Ishii,

Re: Syntax checking DO blocks and ALTER TABLE statements?

2021-02-16 Thread Ron
On 2/16/21 6:19 PM, Tim Cross wrote: Ron writes: On 2/16/21 5:44 PM, Tim Cross wrote: Given the number, I think I would do the same. A good example of why being 'lazy' can be a virtue. Faster and easier to write a procedure to generate dynamic SQL than write out all those alter statements

Re: Syntax checking DO blocks and ALTER TABLE statements?

2021-02-16 Thread Tim Cross
Ron writes: > On 2/16/21 5:44 PM, Tim Cross wrote: >> Given the number, I think I would do the same. A good example of why >> being 'lazy' can be a virtue. Faster and easier to write a procedure to >> generate dynamic SQL than write out all those alter statements manually >> or even write it

Re: Syntax checking DO blocks and ALTER TABLE statements?

2021-02-16 Thread Ron
On 2/16/21 5:44 PM, Tim Cross wrote: Given the number, I think I would do the same. A good example of why being 'lazy' can be a virtue. Faster and easier to write a procedure to generate dynamic SQL than write out all those alter statements manually or even write it using a scripting language

Re: Syntax checking DO blocks and ALTER TABLE statements?

2021-02-16 Thread Tim Cross
David G. Johnston writes: > On Tue, Feb 16, 2021 at 4:28 PM Tim Cross wrote: > >> >> David G. Johnston writes: >> >> > On Tue, Feb 16, 2021 at 3:43 PM Ron wrote: >> > >> >> >> >> How does one go about syntax checking this? >> >> >> >> (There are 222 ALTER TABLE ADD FOREIGN KEY statements

Re: Syntax checking DO blocks and ALTER TABLE statements?

2021-02-16 Thread David G. Johnston
On Tue, Feb 16, 2021 at 4:28 PM Tim Cross wrote: > > David G. Johnston writes: > > > On Tue, Feb 16, 2021 at 3:43 PM Ron wrote: > > > >> > >> How does one go about syntax checking this? > >> > >> (There are 222 ALTER TABLE ADD FOREIGN KEY statements that I'm wrapping > in > >> similar DO

Re: Syntax checking DO blocks and ALTER TABLE statements?

2021-02-16 Thread Tim Cross
David G. Johnston writes: > On Tue, Feb 16, 2021 at 3:43 PM Ron wrote: > >> >> How does one go about syntax checking this? >> >> (There are 222 ALTER TABLE ADD FOREIGN KEY statements that I'm wrapping in >> similar DO blocks, and want to make sure the statements are clean.) >> >> > Begin a

Re: Syntax checking DO blocks and ALTER TABLE statements?

2021-02-16 Thread David G. Johnston
On Tue, Feb 16, 2021 at 3:43 PM Ron wrote: > > How does one go about syntax checking this? > > (There are 222 ALTER TABLE ADD FOREIGN KEY statements that I'm wrapping in > similar DO blocks, and want to make sure the statements are clean.) > > Begin a transaction, execute the DO, capture an

Syntax checking DO blocks and ALTER TABLE statements?

2021-02-16 Thread Ron
How does one go about syntax checking this? do $$ begin if exists (select 1 from information_schema.table_constraints    where constraint_name = 'error_to_web_service_error') then        raise notice 'EXISTS error_to_web_service_error';     else         ALTER TABLE web_service_error   

Re: Order by not working

2021-02-16 Thread Ron
SQL is only intuitive to people who've done programming... :) Also, since your table names are only composed of lower case and underscores, the double quotes are not needed. On 2/16/21 1:41 PM, Dan Nessett wrote: Thanks to those who responded. I have solved my problem by noting the advice to

Re: How to return a jsonb list of lists (with integers)

2021-02-16 Thread David G. Johnston
On Tuesday, February 16, 2021, Alexander Farber wrote: > > But is it possible in SQL to combine all 3 queries, so that a JSONB list > of lists is returned? > So I have to use PL/PgSQL, correct? > With liberal usage of CTEs and subqueries writing a single SQL query should be doable. David J.

Re: How to return a jsonb list of lists (with integers)

2021-02-16 Thread Alexander Farber
Thank you, David, with json_build_array() it works for a single query - SELECT JSONB_BUILD_ARRAY( SUM(CASE WHEN (player1 = in_uid AND state1 = 'won') OR (player2 = in_uid AND state2 = 'won') THEN 1 ELSE 0 END)::integer, SUM(CASE WHEN (player1

Re: How to return a jsonb list of lists (with integers)

2021-02-16 Thread Alexander Farber
On Tue, Feb 16, 2021 at 7:52 PM Michael Lewis wrote: > Aggregate functions work on a single column to summarize many rows into > fewer rows. You seem to be wanting to combine multiple columns which would > be done by concatenation or array[column1,column2] or something like that. > Ah right,

Re: Order by not working

2021-02-16 Thread Dan Nessett
Thanks to those who responded. I have solved my problem by noting the advice to use a select with order by. In particular, I need to export the data to a csv file anyway, so I use the following copy command: COPY (SELECT household_name, family_list, street_address, city, state, zip,

Re: Order by not working

2021-02-16 Thread David G. Johnston
On Tuesday, February 16, 2021, Dan Nessett wrote: > Thanks Peter. The listing of the result is from pg-admin 4.30 using > view/edit data applied to the household_data table. In the past this has > always returned the table contents in the ORDR BY sort order. Do I need to > specify some

Re: Order by not working

2021-02-16 Thread Dan Nessett
Thanks, Dan > On Feb 16, 2021, at 12:11 PM, Ron wrote: > > What would you tell pgadmin? "Order this particular query -- out of all the > billion queries I might write -- in this particular manner?" > > No, that's not how things work. Just add an ORDER BY when you query the > table. > >

Re: Order by not working

2021-02-16 Thread Ron
What would you tell pgadmin?  "Order *this* *particular* query -- out of all the billion queries I might write -- in *this particular* manner?" No, that's not how things work.  Just add an ORDER BY when you query the table. On 2/16/21 12:48 PM, Dan Nessett wrote: Thanks Peter. The listing of

Re: How to return a jsonb list of lists (with integers)

2021-02-16 Thread Michael Lewis
Aggregate functions work on a single column to summarize many rows into fewer rows. You seem to be wanting to combine multiple columns which would be done by concatenation or array[column1,column2] or something like that.

Re: How to return a jsonb list of lists (with integers)

2021-02-16 Thread David G. Johnston
On Tue, Feb 16, 2021 at 11:47 AM Alexander Farber < alexander.far...@gmail.com> wrote: > Thank you for any hints > > json_build_array(...) David J.

Re: Order by not working

2021-02-16 Thread Dan Nessett
Thanks Peter. The listing of the result is from pg-admin 4.30 using view/edit data applied to the household_data table. In the past this has always returned the table contents in the ORDR BY sort order. Do I need to specify some preference in pg_admin to guarantee this? Dan > On Feb 16, 2021,

How to return a jsonb list of lists (with integers)

2021-02-16 Thread Alexander Farber
Good evening, In 13.2 I have 3 SQL queries, which work well and return integer values. The values I feed to Google Charts (and currently I switch to Chart.js). Currently I use the queries by calling 3 different custom stored functions by my Java servlet. I would like to convert the functions

Re: Slow index creation

2021-02-16 Thread Michael Lewis
What is your concern with it taking 20 hours vs 1 hour? Is this index re-created on a regular basis? Would it make any sense to materialize the value of foo(a,b,c) as a generated column (PG12+ natively, or maintained by a trigger before)? Or even bar(foo(a,b,c),geom)? Do you know if

Re: Order by not working

2021-02-16 Thread Peter Coppens
Not sure how you select the household > > The result is (only the first column is shown): > > household_name > > "Garcia" > "Armstrong" > "Armstrong" > "Bauer" > "Bauer" > "Berst" > "Berst" > "Minch ()" > "Berst" > “Besel” but unless you select from the resulting table using again an

Slow index creation

2021-02-16 Thread Paul van der Linden
Hi, I have 2 functions: CREATE FUNCTION foo(a text, b text, c text) RETURNS text AS $func$ DECLARE retVal text; BEGIN SELECT CASE WHEN a='v1' AND b='b1' THEN 'r1' WHEN a='v1' THEN 'r2' ... snip long list containing various tests on a,b and c WHEN

Order by not working

2021-02-16 Thread Dan Nessett
Hello, I am using "PostgreSQL 9.6.5 on x86_64-apple-darwin, compiled by i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00), 64-bit" I am having trouble with a create select statement’s order by clause. The input table,

Re: pg_stat_user_tables.n_mod_since_analyze persistence?

2021-02-16 Thread Philip Semanchuk
> On Feb 15, 2021, at 3:55 PM, Tom Lane wrote: > > Philip Semanchuk writes: >> I saw some unexpected behavior that I'm trying to understand. I suspect it >> might be a quirk specific to AWS Aurora and I'd like to confirm that. > >> When I restart my local Postgres instance (on my Mac), the

Re: Turn jit off for slow subquery in Postgres 12

2021-02-16 Thread Michael Lewis
Either turn it off, or increase jit_above_cost, jit_inline_above_cost, and/or jit_optimize_above_cost.

Re: PostgreSQL Replication

2021-02-16 Thread Mutuku Ndeti
Thanks. Is there a free version of BDR? On Tue, Feb 16, 2021, 5:29 PM Raul Giucich wrote: > This article will help you > https://wiki.postgresql.org/wiki/Multimaster. > > El mar., 16 feb. 2021 10:56, Mutuku Ndeti escribió: > >> Hi, >> >> Need some advice here. I have an application using

Re: Replication sequence

2021-02-16 Thread Paolo Saudin
Thank you! Il giorno mar 16 feb 2021 alle ore 13:38 Jehan-Guillaume de Rorthais < j...@dalibo.com> ha scritto: > On Tue, 16 Feb 2021 13:10:54 +0100 > Paolo Saudin wrote: > > > Il giorno mar 16 feb 2021 alle ore 10:51 Jehan-Guillaume de Rorthais < > > [...] > > > > [...] > > [...] > > [...]

Re: PostgreSQL Replication

2021-02-16 Thread Raul Giucich
This article will help you https://wiki.postgresql.org/wiki/Multimaster. El mar., 16 feb. 2021 10:56, Mutuku Ndeti escribió: > Hi, > > Need some advice here. I have an application using PostgreSQL. I need to > install it on 2 servers for redundancy purposes and have 2 databases. I > need the

PostgreSQL Replication

2021-02-16 Thread Mutuku Ndeti
Hi, Need some advice here. I have an application using PostgreSQL. I need to install it on 2 servers for redundancy purposes and have 2 databases. I need the DBs to replicate to each other, in real-time. Writes can be done on both DBs. Please let me know if this is a feasible setup and the best

Re: Replication sequence

2021-02-16 Thread Jehan-Guillaume de Rorthais
On Tue, 16 Feb 2021 13:10:54 +0100 Paolo Saudin wrote: > Il giorno mar 16 feb 2021 alle ore 10:51 Jehan-Guillaume de Rorthais < > [...] > > [...] > [...] > [...] > [...] > [...] > [...] > [...] > > Thank you very much! > So in case the primary server crashes, and the

Re: Replication sequence

2021-02-16 Thread Paolo Saudin
Il giorno mar 16 feb 2021 alle ore 10:51 Jehan-Guillaume de Rorthais < j...@dalibo.com> ha scritto: > On Mon, 15 Feb 2021 18:55:14 +0100 > Paolo Saudin wrote: > > > Hi all, > > I have two servers, a primary and a secondary one with a streaming > replica > > setup. > > Today I noticed that some

Re: PostgreSQL occasionally unable to rename WAL files (NTFS)

2021-02-16 Thread Thomas Kellerer
Guy Burgess schrieb am 15.02.2021 um 11:52: > The mystery now is that the only process logged as touching the > affected WAL files is postgres.exe (of which there are many separate > processes). Could it be that one of the postgres.exe instances is > holding the affected WAL files in use after

Re: PostgreSQL occasionally unable to rename WAL files (NTFS)

2021-02-16 Thread Guy Burgess
On 16/02/2021 12:23 am, Thorsten Schöning wrote: The mystery now is that the only process logged as touching the affected WAL files is postgres.exe (of which there are many separate processes). Could it be that one of the postgres.exe instances is holding the affected WAL files in use after

Re: Replication sequence

2021-02-16 Thread Jehan-Guillaume de Rorthais
On Mon, 15 Feb 2021 18:55:14 +0100 Paolo Saudin wrote: > Hi all, > I have two servers, a primary and a secondary one with a streaming replica > setup. > Today I noticed that some sequences are not lined-up, the replica ones are > well ahead, while the records number is the same. How is it

Re: [LDAPS] Test connection user with ldaps server

2021-02-16 Thread João Gaspar
Hi all, thanks for the feedback. I was able to do it successfully but I didn't understand yet if there is a bug in pg_hba.conf LDAP link interpretation or a messy domain. So as I said previously, the ldapsearch is finding correctly the user1 fine using only the url dc=company,dc=example,dc=com

Re: ALTER ROLE ... SET in current database only

2021-02-16 Thread Wolfgang Walther
Abdul Qoyyuum: Wouldnt you need to connect to the database first before you can ALTER ROLE anything? Of course, otherwise the notion of "current database" wouldn't make sense at all. But that's only before executing the code. I am not writing and executing this code at the same time. In my