Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nScxN-00083t-CI for pgsql-general@arkaria.postgresql.org; Fri, 11 Mar 2022 10:57:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nScxL-0000oc-5I for pgsql-general@arkaria.postgresql.org; Fri, 11 Mar 2022 10:57:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nScxK-0000oT-Ga for pgsql-general@lists.postgresql.org; Fri, 11 Mar 2022 10:57:10 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nScxG-0002Rx-IV for pgsql-general@postgresql.org; Fri, 11 Mar 2022 10:57:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Reply-To:Message-ID:Subject:Cc:To:Sender:From:Date: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lkI6hlal8KZy860QVzJH/x8BD/Z/EtBrB65GJZFb2fw=; b=NdtT6r1h18J7AmmOXCXrpiH5NB wKg54brpH1MRzbdW5LxFdzV7aCk0Fu5/Fhu+7AwlS2xR/v/dn2yiJfk3GCfD5VO+FcVK3l1sXDQ0P yzdgTEQ3j+XnDpt36atY+nx4XKQx0FdLOq1lJlyIE/U3AQYSw/U8OB7V9AyC4nil1KH8=; Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by depesz.com with esmtpa (Exim 4.92) (envelope-from ) id 1nScxD-0007Ki-19; Fri, 11 Mar 2022 11:57:03 +0100 Date: Fri, 11 Mar 2022 11:57:02 +0100 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Ian Dauncey Cc: "pgsql-general@postgresql.org" Subject: Re: Postgres query Message-ID: <20220311105702.GA24666@depesz.com> Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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