Обсуждение: Postgres query

Поиск
Список
Период
Сортировка

Postgres query

От
Ian Dauncey
Дата:

Hi All

 

Can anyone assist in shedding some light here.

 

We getting this query popping up in our postgresql log file at the same time as the connections to the databases starts increasing.

Not sure what is initiating this query, but we get around a hundred per second until we restart our applications.

Any help will be appreciated.

 

The Query :

 

"select $1[s], s - pg_catalog.array_lower($1,1) + 1

  from pg_catalog.generate_series(pg_catalog.array_lower($1,1),

   pg_catalog.array_upper($1,1),1) as g(s)"

 

Regards

Ian



Disclaimer

The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.

This email has been scanned for viruses and malware, and may have been automatically archived by Mimecast, a leader in email security and cyber resilience. Mimecast integrates email defenses with brand protection, security awareness training, web security, compliance and other essential capabilities. Mimecast helps protect large and small organizations from malicious activity, human error and technology failure; and to lead the movement toward building a more resilient world. To find out more, visit our website.

Re: Postgres query

От
hubert depesz lubaczewski
Дата:
On Fri, Mar 11, 2022 at 10:02:39AM +0000, Ian Dauncey wrote:
> Can anyone assist in shedding some light here.
> We getting this query popping up in our postgresql log file at the same time as the connections to the databases
startsincreasing.
 
> Not sure what is initiating this query, but we get around a hundred per second until we restart our applications.
> Any help will be appreciated.
> "select $1[s], s - pg_catalog.array_lower($1,1) + 1
>   from pg_catalog.generate_series(pg_catalog.array_lower($1,1),
>    pg_catalog.array_upper($1,1),1) as g(s)"

The query simply unpacks given array.

For example, assuming array $1 is '{5,10,15}' it will yield:
 ?column? │ ?column? 
──────────┼──────────
        5 │        1
       10 │        2
       15 │        3
(3 rows)

basically old way to achieve unpacking of array, these days normally it would be called like:

$ select * from unnest('{5,10,15}'::int4[]) with ordinality;
 unnest │ ordinality 
────────┼────────────
      5 │          1
     10 │          2
     15 │          3
(3 rows)

What is running it it's hard to say, the query doesn't strike me as
something that any db driver would call on its own.

depesz