| From: | hubert depesz lubaczewski <depesz(at)depesz(dot)com> | 
|---|---|
| To: | Ian Dauncey <Ian(dot)Dauncey(at)bankzero(dot)co(dot)za> | 
| Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> | 
| Subject: | Re: Postgres query | 
| Date: | 2022-03-11 10:57:02 | 
| Message-ID: | 20220311105702.GA24666@depesz.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general | 
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 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.
> "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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | George Woodring | 2022-03-11 14:48:45 | Re: foreign key on delete cascade order? | 
| Previous Message | Ian Dauncey | 2022-03-11 10:02:39 | Postgres query |