Re: sum of numeric column

2020-12-09 Thread avi Singh
Thanks Adrian for pointing me in the right direction, i got it working On Wed, Dec 9, 2020 at 5:32 PM Adrian Klaver wrote: > On 12/9/20 5:04 PM, avi Singh wrote: > > Thanks for your reply Adrian > > > > > > What do you want to do with the array? > > i want to do a sum of the values of numeric a

Re: sum of numeric column

2020-12-09 Thread Adrian Klaver
On 12/9/20 5:04 PM, avi Singh wrote: Thanks for your reply Adrian What do you want to do with the array? i want to do a sum of the values of numeric array type column e.g. below data_numeric --  {2.0}  {1.0} If you are going to have a single element arrays only then why not just

Re: sum of numeric column

2020-12-09 Thread avi Singh
Thanks for your reply Adrian What do you want to do with the array? i want to do a sum of the values of numeric array type column e.g. below data_numeric -- {2.0} {1.0} (4 rows) Regards On Wed, Dec 9, 2020 at 4:49 PM Adrian Klaver wrote: > On 12/9/20 4:46 PM, avi Singh wro

Re: sum of numeric column

2020-12-09 Thread Adrian Klaver
On 12/9/20 4:46 PM, avi Singh wrote: I have a table structure and want to do a sum of column type i.e numeric. How can I do it ? when i try sum function i get this error You don't have a numeric type you have a numeric array type. ERROR:  function sum(numeric[]) does not exist Hence the er

sum of numeric column

2020-12-09 Thread avi Singh
I have a table structure and want to do a sum of column type i.e numeric. How can I do it ? when i try sum function i get this error ERROR: function sum(numeric[]) does not exist Can anyone please help me with this ? Column | Type | Collation | Nullable

Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?

2020-12-09 Thread electrotype
Agreed. However, this isn't really the purview of JDBC - I'm doubting it does anything that would cause the order to be different than what is received, and the batch items are sent and results processed sequentially. The main question is whether any batch items are inserting multiple record

Re: User input to queries

2020-12-09 Thread Paul Förster
Hi Rich, > On 09. Dec, 2020, at 19:22, Rich Shepard wrote: > > Okay. I use mupdf to view the document and my search string were 'prompt', > and 'prompt command'. I didn't use '\prompt', \prompt is a psql special command, hence the backslash. Only psql knows that, the database does not, as with

Re: User input to queries

2020-12-09 Thread Rich Shepard
On Wed, 9 Dec 2020, Paul Förster wrote: but 12 has it: postgres=# \prompt 'input: ' input input: this is test input postgres=# select version(), :'input'; Paul, Okay. I use mupdf to view the document and my search string were 'prompt', and 'prompt command'. I didn't use '\prompt', Thanks ag

Re: User input to queries

2020-12-09 Thread Paul Förster
Hi Rich, > On 09. Dec, 2020, at 19:10, Rich Shepard wrote: > > Looking at the postgres-12 doc I cannot find a command 'PROMPT' anywhere in > it. but 12 has it: postgres=# \prompt 'input: ' input input: this is test input postgres=# select version(), :'input';

Re: User input to queries

2020-12-09 Thread Rob Sargent
On 12/9/20 11:10 AM, Rich Shepard wrote: On Wed, 9 Dec 2020, Paul Förster wrote: maybe you're looking for this? https://stackoverflow.com/a/7389606 Paul, That looks very useful and I'll try the provided answers. Looking at the postgres-12 doc I cannot find a command 'PROMPT' anywhere in

Re: User input to queries

2020-12-09 Thread Rich Shepard
On Wed, 9 Dec 2020, Paul Förster wrote: maybe you're looking for this? https://stackoverflow.com/a/7389606 Paul, That looks very useful and I'll try the provided answers. Looking at the postgres-12 doc I cannot find a command 'PROMPT' anywhere in it. Thanks, Rich

Re: User input to queries

2020-12-09 Thread Paul Förster
Hi Rich, > On 09. Dec, 2020, at 18:53, Rich Shepard wrote: > > My business tracking tool. Yes, the GUI will have text entry widgets for > user input but I want to apply these queries using psql on the command line > until I build the GUI. maybe you're looking for this? https://stackoverflow.co

Re: User input to queries

2020-12-09 Thread Rich Shepard
On Wed, 9 Dec 2020, Rob Sargent wrote: Put the query in a file, set the desired name, then from psql \i filename Edit pfname, repeat Thanks, Rob. Stay well, Rich

Re: User input to queries [RESOLVED]

2020-12-09 Thread Rich Shepard
On Wed, 9 Dec 2020, Laurenz Albe wrote: You probably need the \prompt psql command: \prompt 'What is "p.lname"' p_lname \prompt 'What is "p.fname"' p_fname SELECT ... WHERE p.lname = :p_lname AND p.fname = :p_fname; Laurenz, Ah! I have not before encountered that command. Yes, this will do th

Re: User input to queries

2020-12-09 Thread Rich Shepard
On Wed, 9 Dec 2020, Michael Lewis wrote: What application is taking the user input and needs to include the parameters in the query string? Michael, My business tracking tool. Yes, the GUI will have text entry widgets for user input but I want to apply these queries using psql on the command

Re: Performance penalty during logical postgres replication

2020-12-09 Thread Victor Yegorov
ср, 9 дек. 2020 г. в 10:21, Lars Vonk : > We are doing a logical postgres replication from Postgres 11 to 12. Our > database is around 700GB (8 cpu's, 32 GB). > During the replication process, at some point, we see a huge performance > penalty on a particular table. This table acts as a queue with

Re: User input to queries

2020-12-09 Thread Laurenz Albe
On Wed, 2020-12-09 at 09:03 -0800, Rich Shepard wrote: > While I develop the application's GUI I use the database from the command > line (psql). While some queries are self-contained others need user input. > I've not found a search term that locates this information in the > postgres-12 user manu

Re: User input to queries

2020-12-09 Thread Rob Sargent
On 12/9/20 10:03 AM, Rich Shepard wrote: While I develop the application's GUI I use the database from the command line (psql). While some queries are self-contained others need user input. I've not found a search term that locates this information in the postgres-12 user manual and my web sea

Re: User input to queries

2020-12-09 Thread Michael Lewis
What application is taking the user input and needs to include the parameters in the query string?

Re: Performance penalty during logical postgres replication

2020-12-09 Thread Michael Lewis
On Wed, Dec 9, 2020 at 2:21 AM Lars Vonk wrote: > Hi, > > We are doing a logical postgres replication from Postgres 11 to 12. Our > database is around 700GB (8 cpu's, 32 GB). > During the replication process, at some point, we see a huge performance > penalty on a particular table. This table act

Re: User input to queries

2020-12-09 Thread Rich Shepard
On Wed, 9 Dec 2020, Michael Lewis wrote: Are you looking for this perhaps? https://www.postgresql.org/docs/current/sql-prepare.html Michael, I don't think so. Reading the PREPARE doc page my understanding is that its use is for statement execution optimization, not asking for user data input

Re: User input to queries

2020-12-09 Thread Michael Lewis
On Wed, Dec 9, 2020 at 10:04 AM Rich Shepard wrote: > While I develop the application's GUI I use the database from the command > line (psql). While some queries are self-contained others need user input. > I've not found a search term that locates this information in the > postgres-12 user manua

User input to queries

2020-12-09 Thread Rich Shepard
While I develop the application's GUI I use the database from the command line (psql). While some queries are self-contained others need user input. I've not found a search term that locates this information in the postgres-12 user manual and my web searches suggest that using '&' should work. I

Re: Potential BRIN Index Corruption

2020-12-09 Thread Tomas Vondra
On 12/9/20 12:07 AM, Huan Ruan wrote: > HI Alvaro > > Unfortunately those records were written a while ago and we no longer keep > their WAL logs. Thanks for your help anyway. > Can you estimate when roughly the records were written? E.g. by using a rough estimate of WAL or XIDs generated per da

Re: Execution order of CTEs / set_config and current_setting in the same query

2020-12-09 Thread Wolfgang Walther
Tom Lane: I think you're on fairly shaky ground here. Generally speaking, a CTE will be executed/read only when the parent query needs the next row from it. Your examples ensure that the CTE is read before the parent query's results are computed; but in realistic usage you'd presumably be joini

Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?

2020-12-09 Thread David G. Johnston
On Wed, Dec 9, 2020 at 8:20 AM electrotype wrote: > So I'm curious. Why does order matter ? > > Dave Cramer > www.postgres.rocks > > > When you have to save multiple new entities with subentities. > > You first save all the parent entities in a single SQL batch insert, you > get the generated ids

Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?

2020-12-09 Thread Dave Cramer
On Wed, 9 Dec 2020 at 10:21, electrotype wrote: > So I'm curious. Why does order matter ? > > Dave Cramer > www.postgres.rocks > > > When you have to save multiple new entities with subentities. > > You first save all the parent entities in a single SQL batch insert, you > get the generated ids,

SV: Tools showing table partitions as tables in listings of tables

2020-12-09 Thread Niels Jespersen
>> A small irritation point is that some tools decide that partitions >> under a table are to be shown in a list of tables, sometimes drowning the >> main table in a sea of partitions. > >While this doesn't answer your question directly, but when I had this problem, >I simply moved partitions to

Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?

2020-12-09 Thread electrotype
So I'm curious. Why does order matter ? Dave Cramer www.postgres.rocks When you have to save multiple new entities with subentities. You first save all the parent entities in a single SQL batch insert, you get the generated ids, then insert all the subentities in another single SQL batch ins

Re: Execution order of CTEs / set_config and current_setting in the same query

2020-12-09 Thread Tom Lane
Wolfgang Walther writes: > Now, we are wondering: To reduce overhead, can we move the set_config > calls to a CTE as part of the main query? The values would need to be > available with current_setting(...) in the remaining query. I think you're on fairly shaky ground here. Generally speaking,

Re: postgres-10 with FIPS

2020-12-09 Thread Joe Conway
On 12/9/20 4:51 AM, Aravindhan Krishnan wrote: > The paid version I had mentioned about was the paid OS (ubuntu) for FIPS > compliancy. I understand that postgres as is completely available for > open-source. > > Since we can't get the paid version of the OS to support FIPS compliancy the > idea

Execution order of CTEs / set_config and current_setting in the same query

2020-12-09 Thread Wolfgang Walther
Hi, with PostgREST [1] we are translating HTTP requests into SQL queries. For each request we are setting some metadata (headers, ...) as GUCs. We used to do it like this: SET LOCAL request.headers.x = 'y'; ... Since this is user-provided data, we want to use parametrized/prepared statements

Re: Tools showing table partitions as tables in listings of tables

2020-12-09 Thread hubert depesz lubaczewski
On Wed, Dec 09, 2020 at 12:29:43PM +, Niels Jespersen wrote: > A small irritation point is that some tools decide that partitions under a > table are to be shown in a list of tables, sometimes > drowning the main table in a sea of partitions. While this doesn't answer your question directly,

Tools showing table partitions as tables in listings of tables

2020-12-09 Thread Niels Jespersen
Hello all We are very happy with the ongoing work on partitioning i Postgres 11+. We use it in a number of cases. A small irritation point is that some tools decide that partitions under a table are to be shown in a list of tables, sometimes drowning the main table in a sea of partitions. PgA

Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?

2020-12-09 Thread Dave Cramer
So I'm curious. Why does order matter ? Dave Cramer www.postgres.rocks On Wed, 9 Dec 2020 at 03:15, electrotype wrote: > I can't see how they could possibly be out of order. > > Thanks, that what I think too. But, to be honest, I'd really like to see > this written in some documentation! In so

Re: postgres-10 with FIPS

2020-12-09 Thread Aravindhan Krishnan
Hi Magnus, The paid version I had mentioned about was the paid OS (ubuntu) for FIPS compliancy. I understand that postgres as is completely available for open-source. Since we can't get the paid version of the OS to support FIPS compliancy the idea was to build postgres against FIPS compliant SSL

Re: postgres-10 with FIPS

2020-12-09 Thread Magnus Hagander
On Wed, Dec 9, 2020 at 5:30 AM Aravindhan Krishnan wrote: > Hi Folks, > > Thanks for the responses. Since the underlying knob flip is a paid version > and we are a SaaS based service provider, this might not align well with > our requirement and so wanted to build postgres-10 against FIPS complia

Performance penalty during logical postgres replication

2020-12-09 Thread Lars Vonk
Hi, We are doing a logical postgres replication from Postgres 11 to 12. Our database is around 700GB (8 cpu's, 32 GB). During the replication process, at some point, we see a huge performance penalty on a particular table. This table acts as a queue with lots of inserts and deletes happening throu

Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?

2020-12-09 Thread electrotype
I can't see how they could possibly be out of order. Thanks, that what I think too. But, to be honest, I'd really like to see this written in some documentation! In some cases, this small detail can be quite important.