Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wUUF0-001C0K-2Z for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jun 2026 18:53:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wUUE0-00Fbxr-2I for pgsql-bugs@arkaria.postgresql.org; Tue, 02 Jun 2026 18:52:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wUUE0-00Fbxi-0F for pgsql-bugs@lists.postgresql.org; Tue, 02 Jun 2026 18:52:28 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wUUDw-00000000n1v-2I4F for pgsql-bugs@lists.postgresql.org; Tue, 02 Jun 2026 18:52:26 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-68c1630159bso5501165a12.2 for ; Tue, 02 Jun 2026 11:52:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1780426342; cv=none; d=google.com; s=arc-20240605; b=QbBWwhAmLCZxZ/ax4GTB97KEWOaXJIm4sUZFOZ7wqG1+AtxN2t83PcyDq6ALNezrb/ wTBZjrPohSga/JjJy4tc7fXjjYDInKErZoDMxM8oKBkx7Dx6t6r5v4RsZAkmZ4APaycI aVqtICVH2DiAO/ijFDc3X47YFHrFkvH5CAdYbGHdfdnDn7leFhjGWPzAciIdb1dZ/ilH mLheEbl+FjtNmcHw2FxIXTiRaNTONax3U2EEg+Rm1F3kJm6RbMgSe4vo69zBUUxWix+S c80swfkDMD4ZjBV/ovt1CJ76IQuM9jcD+eQHGiQBzhQtkvm2sA3XXQSVlTpsOTe3Mdtb BDwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PzLLCUf1gQQVsVdK87Go3bIR9EVstvjNL8yFF8t3AyI=; fh=XkP5gG1lNs0hermOZY1lXlcoBTQFoFr8gt5ocmO42N4=; b=idf6RfsKiUTuQ5FtMMyYOpNmKrAwxVv493SaY7v6sHwdohGgRtuFvE3QnIexJ6d4RS APzmiBziSvbhdWYdCxZX8h5zXjVhDvZE18wJzGGPA+KeZ9X8p6qXL0oEqAVc+SL5Uk5N CRSigMzAqrOtpJSukW3BmkSnt0VVZ3bmDOtZpIZkp9UDWbR1ZWARwT4jGp5w6u72A6nv ZrB7qQHwiY9zmRQhsXzRtebpNSKuDGLLHoLAk7Dw8M0C506zQxJpASFmWLBuwHyflb6I oydURkaIdkEWONDdSoCXI/4CzSDKL/kX5u3A3t5z+4pFU7h6SUVfIKtxEkj34ZDGihGS 5vHg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780426342; x=1781031142; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=PzLLCUf1gQQVsVdK87Go3bIR9EVstvjNL8yFF8t3AyI=; b=Sv6s9krKZLg6+u+QreKGaldFf7RRQ7qt7M/KqFqLkS2gXVJYoMDGBQRwl2YYvUZLRu WlfXjsMMYtGO4qxcMo1UWanDhh+3taOXtWpulvVp4uJOQqrBcoO7bL3Frbl1/ErujosU 3Z6pLDI72jK+sY0fJHnZfRmPKeILbOIuQwoXOTd0M86oq4aZUvkwRxYGqSmJetM/rzXv LAqGCKGhT52PKelYHOqQZx4EPldpVEnw0xfM7r4vQYRsTj0UTKwDdejl79zwndjQu/NY GWE9tTRFScfHH9sujOrNnziC3+gUMoUeXQDnSUSCzgvU318oTFHBVL0wbSWX8IMd0rnO J+YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780426342; x=1781031142; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PzLLCUf1gQQVsVdK87Go3bIR9EVstvjNL8yFF8t3AyI=; b=iGIbPmHnFRSmzmuz05RAOry9KpADkrMzD3H05lJzAWdMqrTsqdXSuOCUQQINQaoRO0 y0WhCR6MMsdKDAbZtGVkEetxzLWvOHULhB7nR5fyJoP3CjzSutIifys9KpHrS9AgANfb EEvfzConJ3UsdyveUmzMZjm8IIrPxpFQD0ncZ1VaoIjOZiQURJ/i6SeVSyhsuj+zJ+7q tSXpTfn50nX39nfJAFEXwV7W4PRHfdlDoIOlp0FueMmkQNLDfH8ytECgz9b1iaxPsQPl ksGmHeATgXXcb0fae0UUYsZkgvZUjf0cdxvjLjCmH/P/7MhdxsyPsLcOnfjgx5en7/7+ YjSw== X-Forwarded-Encrypted: i=1; AFNElJ+QW+w0/KxfcIboeeO4gnGRW/GrSPmGGkD1jfxZ7LOgY3lJAm/Nk2PSPYCHRDd9PLK59babtzZ5WAdy@lists.postgresql.org X-Gm-Message-State: AOJu0YylawzpbjfEEhkCVf1NIiw82SVmly+PgaXj6DH4ncpZ7v7mnnhR pQhpqLWZgUiZY4VO9J60f56R2wdVl3XTZON1lFozYBCqoowcs5bgE7tRDayZ0UnKUL0vxaI/+cN RBlM5/hSKQDApfs5sI0Yq8RSpfcCwFv1aQAoU X-Gm-Gg: Acq92OHCUkPFblsk+txd8TFsqfv5EHFBlykuitYYIad9SeXpqukv8RtngRUlS5LKJWr ih/kTrhmXbF0n+f0wDgQqeHBAhxVdryqaBhBc2ir+Y5B36+uoJxtvFqiWkAHp6G8EtNcCeAsQCc 9Sh1l4CbIDTA7eNLGgExsNgDDJykggtlcUeI3YhkzsoJ0+KJmc6TDQx2GvuxkrFuSmWojEJK6fN gVOWTUmPE7nzKz8m6EJkfpUsdzuUlRcmex0uO48qavG1KO42f+NdHuHWfBqocRaBTlHJHc6UNgJ 0xC3zgacdG7uiEreoStXiV7AaqEVST+367tm+3otGNoSsjE8JaPrKV/XuM6h3B5IyjfTUJw= X-Received: by 2002:a05:6402:a181:b0:687:74de:985b with SMTP id 4fb4d7f45d1cf-68e5db4d6a6mr446547a12.14.1780426341937; Tue, 02 Jun 2026 11:52:21 -0700 (PDT) MIME-Version: 1.0 References: <19505-7ec445dffe2732d2@postgresql.org> In-Reply-To: <19505-7ec445dffe2732d2@postgresql.org> From: Maxim Boguk Date: Tue, 2 Jun 2026 21:51:43 +0300 X-Gm-Features: AVHnY4Iedo01__J6amqhVwZN_CVwtq7OFcN2pxVikSuwMz4vxbxi3mWC2mGiEQE Message-ID: Subject: Re: BUG #19505: Some weird spikes postgresql processes in database (up to 200k sometime) without apparent reasons. To: maxim.boguk@gmail.com, pgsql-bugs@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000a8f591065349cff5" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a8f591065349cff5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jun 2, 2026 at 9:37=E2=80=AFPM PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 19505 > Logged by: Maxim Boguk > Email address: maxim.boguk@gmail.com > PostgreSQL version: 18.4 > Operating system: Ubuntu 24.04.4 LTS > Description: > > I started investigation of this issue after found that process count of > postgresql on my replica sometime jump to 200k+ (with max_connections=3D1= 000 > and real connections under 100 most time). > Somehow single (seems random by always heavy/analytical) query spawn > thousands of the threads and tens thousands of parallel workers. > > After some logging I caught one snapshot (ps -u postgres -L -o > pid,tid,ppid,lstart,args -ww 2 ) with 39257 processes: > > [postgres@db ~/tmp]$ zcat ps-L-2026-06-02_17-40-22.gz | wc -l > 39257 > > Main content is: > PID TID PPID StartTime > command > 2158552 2158552 948705 Tue Jun 2 17:40:17 2026 postgres: 18/main: > background_shared db [local] SELECT > > Then: > The same PID but 1620 different TIDS. > PID TID PPID StartTime > command > #main process > 2158557 2158557 948705 Tue Jun 2 17:40:18 2026 postgres: 18/main: > background_shared db [local] SELECT > #1620 threads > 2158557 2158607 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: > background_shared db [local] SELECT > 2158557 2158608 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: > background_shared db [local] SELECT > 2158557 2158609 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: > background_shared db [local] SELECT > > Then, 37571 rows!!! of: > PID TID PPID StartTime > command > 2158579 2159176 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: > parallel > worker for PID 2158557 > 2158579 2159179 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: > parallel > worker for PID 2158557 > 2158579 2159183 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: > parallel > worker for PID 2158557 > 2158579 2159196 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: > parallel > worker for PID 2158557 > 2158579 2159198 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: > parallel > worker for PID 2158557 > 2158579 2159202 948705 Tue Jun 2 17:40:20 2026 postgres: 18/main: > parallel > worker for PID 2158557 > > I double checked the query (it had been logged in database log): it run > with > 6 worker processes and without any issues on manual run. > > Related db configuration: > max_connections =3D 1000 > max_worker_processes =3D 128 # (change requires restart) > max_parallel_workers_per_gather =3D 16 # limited by max_parallel_worke= rs > max_parallel_workers =3D 64 > io_method =3D io_uring # worker, io_uring, sync > io_max_concurrency =3D -1 # Max number of IOs that one process > jit =3D on (usual suspect in case of weird things going on) > > Given that situation happens like 1-10 times per hour (and lead for short > LA > spikes up to 10000) - it's seriously affect the database replica > performance. > > No external/non-standard/C extensions except of pgq and postgis loaded in= to > the database. > > I can look for any additional information and perform any local research > but currently I'm out of ideas what my next steps should be. > > PS: it's seems that the issue could be triggered by different queries, bu= t > not the one particular. > > UPD: Looks like the issue is always triggered by queries of the same kind (below query and explain), but I can't see any way how this query can spawn 10k-100k threads (or spawn any threads at all). PS: The problem started after upgrading 17->18, so the next suspect I am going to test is "io_method =3D io_uring". explain analyze WITH _tmp as ( SELECT "job_stats_master"."device", "job_stats_master"."organic", "job_stats_master"."paid", "job_stats_master"."global_action", "job_stats_master"."employer_id", SUM(COALESCE(stats_count, 1)), sum(coalesce(price, 0)) AS spent, DATE(job_stats_master.created_at AT TIME ZONE 'UTC' AT TIME ZONE 'Etc/UTC'), coalesce(SUM(price) filter(where bid_metric_matches(bid_metric, global_action) AND paid AND NOT organic), 0) earned, "job_stats_master"."job_board_id", "job_stats_master"."job_group_id", "job_stats_master"."country_id", "job_stats_master"."gcc", "job_stats_master"."exchange_id", "job_stats_master"."bid_metric", sum(coalesce(price_publisher, 0)), sum(coalesce(cpc, 0)), sum(coalesce(price, 0) * coalesce(ncc, 1)) AS spent_ncc, sum(coalesce(price, 0) / coalesce(gcc, 1)) AS spent_gcc, sum(coalesce(price_publisher, 0)) AS publisher_spent FROM "job_stats_master" WHERE "job_stats_master"."job_board_id" =3D 30875 AND (job_stats_master.created_at >=3D '2026-05-01 00:00:00') AND (job_stats_master.created_at <=3D '2026-05-31 23:59:59.999999') AND ((job_stats_master.unpaid_reason NOT IN (7, 9, 19) OR job_stats_master.unpaid_reason IS NULL)) AND "job_stats_master"."employer_id" NOT IN (20894, 28518, 28508, 28517, 20691, 24731, 28280, 20692, 20690, 28281, 28509, 20700, 28284, 28520, 20895, 24730, 20698, 20699, 28285, 28519, 28521, 28613, 28607, 28612, 28602, 28603, 28604, 28610, 28605, 28606, 28608, 28609, 28614, 28615, 28611, 28629, 28630, 28625, 28626, 28627, 28633, 28632, 28622, 28624, 28620, 28621, 28623, 28628, 28631, 28652, 28653, 28654, 28658, 28656, 28647, 28648, 28651, 28649, 28655, 28650, 28659, 28657, 28660, 20893, 28279, 19292, 28527, 19291, 28278, 24707, 19290, 28526, 28525, 18157, 18158, 18156, 18155, 28255, 28256, 28258, 28259, 28260, 24689, 28262, 28265, 28268, 28267, 24688, 28257, 22774, 20701, 28283, 21597, 24729, 20702, 22781, 20703, 20896, 28282, 28524, 22780, 28522, 28523, 7400, 7397, 7399, 8118, 8110, 7402, 6706, 6700, 6703, 8113, 8108, 9457, 8109, 9453, 7068, 8114, 7401, 9456, 6866, 8117, 9455, 8115, 7398, 6707, 7403, 9454, 7404, 8116, 6708, 21129, 21130, 21131, 21132, 24369, 24364, 24368, 24365, 24367, 24366, 18576, 18574, 18575, 18573, 24433, 21414, 2887, 60, 62, 61, 10381, 20676, 20677, 20851, 20972, 18220, 18219, 18221, 18222, 3182, 3158, 3157, 5213, 5212, 3156, 3839, 3840, 6919, 5818, 6951, 9502, 3841, 10489, 10490, 10491, 15231, 10493, 15232, 10492, 9189, 9185, 9187, 9188, 9190, 9186, 8898, 8900, 8897, 8899, 8895, 8896, 8912, 8909, 8914, 8913, 8911, 8910, 18184, 18182, 18185, 18183, 10858, 20706, 10861, 10859, 10857, 10860, 19570, 8906, 8908, 8907, 8904, 8905, 8903, 7686, 7685, 7684, 7682, 7687, 7683, 7689, 7692, 7688, 7693, 7690, 7691, 9503, 8225, 11593, 8223, 8227, 8222, 8226, 8224, 3295, 3294, 4151, 10468, 3293, 4081, 5668, 3153, 3152, 3154, 3480, 3148, 3150, 3482, 3149, 3291, 3292, 13708, 3987, 3290, 3533, 20675, 10298, 10290, 10297, 10299, 10296, 3286, 3284, 5320, 3951, 3907, 3459, 3285, 3529, 3289, 3288, 3287, 6894, 19552, 7873, 6240, 21467, 6816, 17328, 4598, 4599, 4600, 18244) GROUP BY "job_stats_master"."device", "job_stats_master"."organic", "job_stats_master"."paid", "job_stats_master"."global_action", "job_stats_master"."employer_id", "job_stats_master"."job_board_id", "job_stats_master"."job_group_id", "job_stats_master"."country_id", DATE(job_stats_master.created_at AT TIME ZONE 'UTC' AT TIME ZONE 'Etc/UTC'), "job_stats_master"."gcc", "job_stats_master"."exchange_id", "job_stats_master"."bid_metric" ) SELECT employers.enterprise_id AS tier0_enterprise_id, _tmp.* FROM _tmp INNER JOIN employers on employers.id =3D _tmp.employer_id ; QUERY PLAN ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= -------------- Hash Join (cost=3D117116.37..156282.19 rows=3D556873 width=3D280) (actual time=3D626.650..1874.724 rows=3D313222.00 loops=3D1) Hash Cond: (job_stats_master.employer_id =3D employers.id) Buffers: shared hit=3D505859 -> Finalize GroupAggregate (cost=3D115548.94..154129.81 rows=3D556873 width=3D276) (actual time=3D593.246..1799.007 rows=3D313222.00 loops=3D1) Group Key: job_stats_master.device, job_stats_master.organic, job_stats_master.paid, job_stats_master.global_action, job_stats_master.employer_id, job_stats_master.job_group_id, job_stats_master.country_id, (date(((job_stats_master.created_at AT TIME ZONE 'UTC'::text) AT TIME ZONE 'Etc/UTC'::text))), job_stats_master.gcc, job_stats_master.exchange_id, job_stats_master.bid_metric Buffers: shared hit=3D495471 -> Gather Merge (cost=3D115548.94..130184.30 rows=3D556872 width=3D244) (actual time=3D593.228..1242.326 rows=3D475158.00 loops=3D1) Workers Planned: 6 Workers Launched: 6 Buffers: shared hit=3D495471 -> Partial GroupAggregate (cost=3D105548.90..110653.56 rows=3D92812 width=3D244) (actual time=3D569.484..682.066 rows=3D67879.71 l= oops=3D7) Group Key: job_stats_master.device, job_stats_master.organic, job_stats_master.paid, job_stats_master.global_action, job_stats_master.employer_id, job_stats_master.job_group_id, job_stats_master.country_id, (date(((job_stats_master.created_at AT TIME ZONE 'UTC'::text) AT TIME ZONE 'Etc/UTC'::text))), job_stats_master.gcc, job_stats_master.exchange_id, job_stats_master.bid_metric Buffers: shared hit=3D495471 -> Sort (cost=3D105548.90..105641.71 rows=3D92812 width=3D72) (actual time=3D569.430..580.918 rows=3D87120.71 loops=3D7) Sort Key: job_stats_master.device, job_stats_master.organic, job_stats_master.paid, job_stats_master.global_action, job_stats_master.employer_id, job_stats_master.job_group_id, job_stats_master.country_id, (date(((job_stats_master.created_at AT TIME ZONE 'UTC'::text) AT TIME ZONE 'Etc/UTC'::text))), job_stats_master.gcc, job_stats_master.exchange_id, job_stats_master.bid_metric Sort Method: quicksort Memory: 10559kB Buffers: shared hit=3D495471 Worker 0: Sort Method: quicksort Memory: 9807k= B Worker 1: Sort Method: quicksort Memory: 9684k= B Worker 2: Sort Method: quicksort Memory: 9818k= B Worker 3: Sort Method: quicksort Memory: 9772k= B Worker 4: Sort Method: quicksort Memory: 9764k= B Worker 5: Sort Method: quicksort Memory: 9702k= B -> Parallel Bitmap Heap Scan on job_stats_new_2026_05 job_stats_master (cost=3D34412.46..102021.67 rows=3D92812 width=3D72) (actual time=3D174.110..463.709 rows=3D87120.71 lo= ops=3D7) Recheck Cond: ((job_board_id =3D 30875) AN= D (created_at >=3D '2026-05-01 00:00:00'::timestamp without time zone) AND (created_at <=3D '2026-05-31 23:59:59.999999'::timestamp without time zone)= ) Filter: (((unpaid_reason <> ALL ('{7,9,19}'::integer[])) OR (unpaid_reason IS NULL)) AND (employer_id <> ALL ('{20894,28518,28508,28517,20691,24731,28280,20692,20690,28281,28509,20700,= 28284,28520,20895,24730,20698,20699,28285,28519,28521,28613,28607,28612,286= 02,28603,28604,28610,28605,28606,28608,28609,28614,28615,28611,28629,28630,= 28625,28626,28627,28633,28632,28622,28624,28620,28621,28623,28628,28631,286= 52,28653,28654,28658,28656,28647,28648,28651,28649,28655,28650,28659,28657,= 28660,20893,28279,19292,28527,19291,28278,24707,19290,28526,28525,18157,181= 58,18156,18155,28255,28256,28258,28259,28260,24689,28262,28265,28268,28267,= 24688,28257,22774,20701,28283,21597,24729,20702,22781,20703,20896,28282,285= 24,22780,28522,28523,7400,7397,7399,8118,8110,7402,6706,6700,6703,8113,8108= ,9457,8109,9453,7068,8114,7401,9456,6866,8117,9455,8115,7398,6707,7403,9454= ,7404,8116,6708,21129,21130,21131,21132,24369,24364,24368,24365,24367,24366= ,18576,18574,18575,18573,24433,21414,2887,60,62,61,10381,20676,20677,20851,= 20972,18220,18219,18221,18222,3182,3158,3157,5213,5212,3156,3839,3840,6919,= 5818,6951,9502,3841,10489,10490,10491,15231,10493,15232,10492,9189,9185,918= 7,9188,9190,9186,8898,8900,8897,8899,8895,8896,8912,8909,8914,8913,8911,891= 0,18184,18182,18185,18183,10858,20706,10861,10859,10857,10860,19570,8906,89= 08,8907,8904,8905,8903,7686,7685,7684,7682,7687,7683,7689,7692,7688,7693,76= 90,7691,9503,8225,11593,8223,8227,8222,8226,8224,3295,3294,4151,10468,3293,= 4081,5668,3153,3152,3154,3480,3148,3150,3482,3149,3291,3292,13708,3987,3290= ,3533,20675,10298,10290,10297,10299,10296,3286,3284,5320,3951,3907,3459,328= 5,3529,3289,3288,3287,6894,19552,7873,6240,21467,6816,17328,4598,4599,4600,= 18244}'::integer[]))) Rows Removed by Filter: 45 Heap Blocks: exact=3D76322 Buffers: shared hit=3D495195 Worker 0: Heap Blocks: exact=3D69229 Worker 1: Heap Blocks: exact=3D67759 Worker 2: Heap Blocks: exact=3D69407 Worker 3: Heap Blocks: exact=3D68584 Worker 4: Heap Blocks: exact=3D68597 Worker 5: Heap Blocks: exact=3D67828 -> Bitmap Index Scan on job_stats_new_2026_05_job_board_id_job_reference_created_at_idx (cost=3D0.00..34356.49 rows=3D635582 width=3D0) (actual time=3D90.252..90.= 253 rows=3D610218.00 loops=3D1) Index Cond: ((job_board_id =3D 30875= ) AND (created_at >=3D '2026-05-01 00:00:00'::timestamp without time zone) AN= D (created_at <=3D '2026-05-31 23:59:59.999999'::timestamp without time zone)= ) Index Searches: 1 Buffers: shared hit=3D7343 -> Hash (cost=3D1290.53..1290.53 rows=3D25173 width=3D8) (actual time=3D33.285..33.292 rows=3D25173.00 loops=3D1) Buckets: 32768 Batches: 1 Memory Usage: 1240kB Buffers: shared hit=3D10388 -> Seq Scan on employers (cost=3D0.00..1290.53 rows=3D25173 widt= h=3D8) (actual time=3D18.012..30.607 rows=3D25173.00 loops=3D1) Buffers: shared hit=3D10388 Planning: Buffers: shared hit=3D1212 Planning Time: 2.535 ms JIT: Functions: 88 Options: Inlining false, Optimization false, Expressions true, Deforming true Timing: Generation 11.607 ms (Deform 5.619 ms), Inlining 0.000 ms, Optimization 7.214 ms, Emission 90.846 ms, Total 109.668 ms Execution Time: 1902.285 ms --=20 Maxim Boguk Senior Postgresql DBA Phone UA: +380 99 143 0000 Phone AU: +61 45 218 5678 --000000000000a8f591065349cff5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Jun 2, 2026 at 9:37=E2=80=AFPM PG Bug reporting form <noreply@postgresql.org> wrote:
The following bug = has been logged on the website:

Bug reference:=C2=A0 =C2=A0 =C2=A0 19505
Logged by:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Maxim Boguk
Email address:=C2=A0 =C2=A0 =C2=A0 maxim.boguk@gmail.com
PostgreSQL version: 18.4
Operating system:=C2=A0 =C2=A0Ubuntu 24.04.4 LTS
Description:=C2=A0 =C2=A0 =C2=A0 =C2=A0

I started investigation of this issue after found that process count of
postgresql on my replica sometime jump to 200k+ (with max_connections=3D100= 0
and real connections under 100 most time).
Somehow single (seems random by always heavy/analytical) query spawn
thousands of the threads and tens thousands of parallel workers.

After some logging I caught one snapshot (ps -u postgres -L -o
pid,tid,ppid,lstart,args -ww 2 ) with 39257 processes:

[postgres@db ~/tmp]$ zcat ps-L-2026-06-02_17-40-22.gz | wc -l
39257

Main content is:
PID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 TID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0PPID=C2=A0 StartTime
command
2158552 2158552=C2=A0 948705 Tue Jun=C2=A0 2 17:40:17 2026 postgres: 18/mai= n:
background_shared db [local] SELECT

Then:
The same PID but 1620 different TIDS.
PID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 TID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0PPID=C2=A0 StartTime
command
#main process
2158557 2158557=C2=A0 948705 Tue Jun=C2=A0 2 17:40:18 2026 postgres: 18/mai= n:
background_shared db [local] SELECT
#1620 threads
2158557 2158607=C2=A0 948705 Tue Jun=C2=A0 2 17:40:20 2026 postgres: 18/mai= n:
background_shared db [local] SELECT
2158557 2158608=C2=A0 948705 Tue Jun=C2=A0 2 17:40:20 2026 postgres: 18/mai= n:
background_shared db [local] SELECT
2158557 2158609=C2=A0 948705 Tue Jun=C2=A0 2 17:40:20 2026 postgres: 18/mai= n:
background_shared db [local] SELECT

Then, 37571 rows!!! of:
PID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 TID=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0PPID=C2=A0 StartTime
command
2158579 2159176=C2=A0 948705 Tue Jun=C2=A0 2 17:40:20 2026 postgres: 18/mai= n: parallel
worker for PID 2158557
2158579 2159179=C2=A0 948705 Tue Jun=C2=A0 2 17:40:20 2026 postgres: 18/mai= n: parallel
worker for PID 2158557
2158579 2159183=C2=A0 948705 Tue Jun=C2=A0 2 17:40:20 2026 postgres: 18/mai= n: parallel
worker for PID 2158557
2158579 2159196=C2=A0 948705 Tue Jun=C2=A0 2 17:40:20 2026 postgres: 18/mai= n: parallel
worker for PID 2158557
2158579 2159198=C2=A0 948705 Tue Jun=C2=A0 2 17:40:20 2026 postgres: 18/mai= n: parallel
worker for PID 2158557
2158579 2159202=C2=A0 948705 Tue Jun=C2=A0 2 17:40:20 2026 postgres: 18/mai= n: parallel
worker for PID 2158557

I double checked the query (it had been logged in database log): it run wit= h
6 worker processes and without any issues on manual run.

Related db configuration:
max_connections =3D 1000
max_worker_processes =3D 128=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 # (change requires restart)
max_parallel_workers_per_gather =3D 16=C2=A0 =C2=A0 # limited by max_parall= el_workers
max_parallel_workers =3D 64
io_method =3D io_uring=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 # worker, io_uring, sync
io_max_concurrency =3D -1=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0# Max number of = IOs that one process
jit =3D on (usual suspect in case of weird things going on)

Given that situation happens like 1-10 times per hour (and lead for short L= A
spikes up to 10000) - it's seriously affect the database replica
performance.

No external/non-standard/C extensions except of pgq and postgis loaded into=
the database.

I can look for any additional information and=C2=A0 perform any local resea= rch
but currently I'm out of ideas what my next steps should be.

PS: it's seems that the issue could be triggered by different queries, = but
not the one particular.


UPD:
Looks like the issue is always triggered by queries of = the same kind (below query and explain),
but I can't s= ee any way how this query can spawn 10k-100k threads (or spawn any threads = at all).
PS: The problem started after upgrading 17->18= , so the next suspect I am going to test is=C2=A0"= io_method =3D io_uring".

explai= n analyze =C2=A0WITH _tmp as (
SELECT
"job_stats_master".&= quot;device", "job_stats_master"."organic", "= job_stats_master"."paid", "job_stats_master"."= ;global_action", "job_stats_master"."employer_id",=
SUM(COALESCE(stats_count, 1)), sum(coalesce(price, 0)) AS spent, DATE(= job_stats_master.created_at AT TIME ZONE 'UTC' AT TIME ZONE 'Et= c/UTC'),
coalesce(SUM(price) filter(where bid_metric_matches(bid_me= tric, global_action) AND paid AND NOT organic), 0) earned,
"job_st= ats_master"."job_board_id", "job_stats_master".&qu= ot;job_group_id", "job_stats_master"."country_id",= "job_stats_master"."gcc", "job_stats_master"= ."exchange_id", "job_stats_master"."bid_metric&quo= t;,
sum(coalesce(price_publisher, 0)), sum(coalesce(cpc, 0)), sum(coale= sce(price, 0) * coalesce(ncc, 1)) AS spent_ncc, sum(coalesce(price, 0) / co= alesce(gcc, 1)) AS spent_gcc, sum(coalesce(price_publisher, 0)) AS publishe= r_spent
FROM "job_stats_master"
WHERE
"job_stats= _master"."job_board_id" =3D 30875
AND (job_stats_master.= created_at >=3D '2026-05-01 00:00:00')
AND (job_stats_master= .created_at <=3D '2026-05-31 23:59:59.999999')
AND ((job_sta= ts_master.unpaid_reason NOT IN (7, 9, 19) OR job_stats_master.unpaid_reason= IS NULL))
AND "job_stats_master"."employer_id" NOT= IN (20894, 28518, 28508, 28517, 20691, 24731, 28280, 20692, 20690, 28281, = 28509, 20700, 28284, 28520, 20895, 24730, 20698, 20699, 28285, 28519, 28521= , 28613, 28607, 28612, 28602, 28603, 28604, 28610, 28605, 28606, 28608, 286= 09, 28614, 28615, 28611, 28629, 28630, 28625, 28626, 28627, 28633, 28632, 2= 8622, 28624, 28620, 28621, 28623, 28628, 28631, 28652, 28653, 28654, 28658,= 28656, 28647, 28648, 28651, 28649, 28655, 28650, 28659, 28657, 28660, 2089= 3, 28279, 19292, 28527, 19291, 28278, 24707, 19290, 28526, 28525, 18157, 18= 158, 18156, 18155, 28255, 28256, 28258, 28259, 28260, 24689, 28262, 28265, = 28268, 28267, 24688, 28257, 22774, 20701, 28283, 21597, 24729, 20702, 22781= , 20703, 20896, 28282, 28524, 22780, 28522, 28523, 7400, 7397, 7399, 8118, = 8110, 7402, 6706, 6700, 6703, 8113, 8108, 9457, 8109, 9453, 7068, 8114, 740= 1, 9456, 6866, 8117, 9455, 8115, 7398, 6707, 7403, 9454, 7404, 8116, 6708, = 21129, 21130, 21131, 21132, 24369, 24364, 24368, 24365, 24367, 24366, 18576= , 18574, 18575, 18573, 24433, 21414, 2887, 60, 62, 61, 10381, 20676, 20677,= 20851, 20972, 18220, 18219, 18221, 18222, 3182, 3158, 3157, 5213, 5212, 31= 56, 3839, 3840, 6919, 5818, 6951, 9502, 3841, 10489, 10490, 10491, 15231, 1= 0493, 15232, 10492, 9189, 9185, 9187, 9188, 9190, 9186, 8898, 8900, 8897, 8= 899, 8895, 8896, 8912, 8909, 8914, 8913, 8911, 8910, 18184, 18182, 18185, 1= 8183, 10858, 20706, 10861, 10859, 10857, 10860, 19570, 8906, 8908, 8907, 89= 04, 8905, 8903, 7686, 7685, 7684, 7682, 7687, 7683, 7689, 7692, 7688, 7693,= 7690, 7691, 9503, 8225, 11593, 8223, 8227, 8222, 8226, 8224, 3295, 3294, 4= 151, 10468, 3293, 4081, 5668, 3153, 3152, 3154, 3480, 3148, 3150, 3482, 314= 9, 3291, 3292, 13708, 3987, 3290, 3533, 20675, 10298, 10290, 10297, 10299, = 10296, 3286, 3284, 5320, 3951, 3907, 3459, 3285, 3529, 3289, 3288, 3287, 68= 94, 19552, 7873, 6240, 21467, 6816, 17328, 4598, 4599, 4600, 18244)
GROU= P BY "job_stats_master"."device", "job_stats_maste= r"."organic", "job_stats_master"."paid",= "job_stats_master"."global_action", "job_stats_ma= ster"."employer_id", "job_stats_master"."job_= board_id", "job_stats_master"."job_group_id", &quo= t;job_stats_master"."country_id", DATE(job_stats_master.crea= ted_at AT TIME ZONE 'UTC' AT TIME ZONE 'Etc/UTC'), "jo= b_stats_master"."gcc", "job_stats_master"."ex= change_id", "job_stats_master"."bid_metric"
)=C2=A0 =C2=A0 =C2=A0 =C2=A0 SELECT employers.enterprise_id AS tier0_enter= prise_id, _tmp.*
=C2=A0 =C2=A0 =C2=A0 =C2=A0 FROM _tmp
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 INNER JOIN employers on emplo= yers.id =3D _tmp.employer_id
;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0QUERY PLAN=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0
-----------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= ------------------------------------------------------------------------=C2=A0Hash Join =C2=A0(cost=3D117116.37..156282.19 rows=3D556873 width=3D2= 80) (actual time=3D626.650..1874.724 rows=3D313222.00 loops=3D1)
=C2=A0 = =C2=A0Hash Cond: (job_stats_master.employer_id =3D employers.id)
=C2=A0 =C2=A0Buffers: shared hit=3D505859
= =C2=A0 =C2=A0-> =C2=A0Finalize GroupAggregate =C2=A0(cost=3D115548.94..1= 54129.81 rows=3D556873 width=3D276) (actual time=3D593.246..1799.007 rows= =3D313222.00 loops=3D1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Group Key: job= _stats_master.device, job_stats_master.organic, job_stats_master.paid, job_= stats_master.global_action, job_stats_master.employer_id, job_stats_master.= job_group_id, job_stats_master.country_id, (date(((job_stats_master.created= _at AT TIME ZONE 'UTC'::text) AT TIME ZONE 'Etc/UTC'::text)= )), job_stats_master.gcc, job_stats_master.exchange_id, job_stats_master.bi= d_metric
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hit=3D495471<= br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> =C2=A0Gather Merge =C2=A0(cost= =3D115548.94..130184.30 rows=3D556872 width=3D244) (actual time=3D593.228..= 1242.326 rows=3D475158.00 loops=3D1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0Workers Planned: 6
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0Workers Launched: 6
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hit=3D495471
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> =C2=A0Partial GroupAggregate= =C2=A0(cost=3D105548.90..110653.56 rows=3D92812 width=3D244) (actual time= =3D569.484..682.066 rows=3D67879.71 loops=3D7)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Group Key: job_stats_ma= ster.device, job_stats_master.organic, job_stats_master.paid, job_stats_mas= ter.global_action, job_stats_master.employer_id, job_stats_master.job_group= _id, job_stats_master.country_id, (date(((job_stats_master.created_at AT TI= ME ZONE 'UTC'::text) AT TIME ZONE 'Etc/UTC'::text))), job_s= tats_master.gcc, job_stats_master.exchange_id, job_stats_master.bid_metric<= br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0Buffers: shared hit=3D495471
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> =C2=A0Sort =C2=A0(cost=3D105= 548.90..105641.71 rows=3D92812 width=3D72) (actual time=3D569.430..580.918 = rows=3D87120.71 loops=3D7)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Sort Key: job_stats_mas= ter.device, job_stats_master.organic, job_stats_master.paid, job_stats_mast= er.global_action, job_stats_master.employer_id, job_stats_master.job_group_= id, job_stats_master.country_id, (date(((job_stats_master.created_at AT TIM= E ZONE 'UTC'::text) AT TIME ZONE 'Etc/UTC'::text))), job_st= ats_master.gcc, job_stats_master.exchange_id, job_stats_master.bid_metric=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0Sort Method: quicksort =C2=A0Memory: 10559kB
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0Buffers: shared hit=3D495471
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0Worker 0: =C2=A0Sort Method: quicksort =C2=A0Memory: 9807kB
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0Worker 1: =C2=A0Sort Method: quicksort =C2=A0Memory: 9684k= B
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 2: =C2=A0Sort Method: quicksort =C2=A0Mem= ory: 9818kB
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 3: =C2=A0Sort Method: quicksor= t =C2=A0Memory: 9772kB
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 4: =C2=A0Sort Method= : quicksort =C2=A0Memory: 9764kB
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 5: =C2=A0= Sort Method: quicksort =C2=A0Memory: 9702kB
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> = =C2=A0Parallel Bitmap Heap Scan on job_stats_new_2026_05 job_stats_master = =C2=A0(cost=3D34412.46..102021.67 rows=3D92812 width=3D72) (actual time=3D1= 74.110..463.709 rows=3D87120.71 loops=3D7)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0Recheck Cond: ((job_board_id =3D 30875) AND (created_at &g= t;=3D '2026-05-01 00:00:00'::timestamp without time zone) AND (crea= ted_at <=3D '2026-05-31 23:59:59.999999'::timestamp without time= zone))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Filter: (((unpaid_re= ason <> ALL ('{7,9,19}'::integer[])) OR (unpaid_reason IS NUL= L)) AND (employer_id <> ALL ('{20894,28518,28508,28517,20691,2473= 1,28280,20692,20690,28281,28509,20700,28284,28520,20895,24730,20698,20699,2= 8285,28519,28521,28613,28607,28612,28602,28603,28604,28610,28605,28606,2860= 8,28609,28614,28615,28611,28629,28630,28625,28626,28627,28633,28632,28622,2= 8624,28620,28621,28623,28628,28631,28652,28653,28654,28658,28656,28647,2864= 8,28651,28649,28655,28650,28659,28657,28660,20893,28279,19292,28527,19291,2= 8278,24707,19290,28526,28525,18157,18158,18156,18155,28255,28256,28258,2825= 9,28260,24689,28262,28265,28268,28267,24688,28257,22774,20701,28283,21597,2= 4729,20702,22781,20703,20896,28282,28524,22780,28522,28523,7400,7397,7399,8= 118,8110,7402,6706,6700,6703,8113,8108,9457,8109,9453,7068,8114,7401,9456,6= 866,8117,9455,8115,7398,6707,7403,9454,7404,8116,6708,21129,21130,21131,211= 32,24369,24364,24368,24365,24367,24366,18576,18574,18575,18573,24433,21414,= 2887,60,62,61,10381,20676,20677,20851,20972,18220,18219,18221,18222,3182,31= 58,3157,5213,5212,3156,3839,3840,6919,5818,6951,9502,3841,10489,10490,10491= ,15231,10493,15232,10492,9189,9185,9187,9188,9190,9186,8898,8900,8897,8899,= 8895,8896,8912,8909,8914,8913,8911,8910,18184,18182,18185,18183,10858,20706= ,10861,10859,10857,10860,19570,8906,8908,8907,8904,8905,8903,7686,7685,7684= ,7682,7687,7683,7689,7692,7688,7693,7690,7691,9503,8225,11593,8223,8227,822= 2,8226,8224,3295,3294,4151,10468,3293,4081,5668,3153,3152,3154,3480,3148,31= 50,3482,3149,3291,3292,13708,3987,3290,3533,20675,10298,10290,10297,10299,1= 0296,3286,3284,5320,3951,3907,3459,3285,3529,3289,3288,3287,6894,19552,7873= ,6240,21467,6816,17328,4598,4599,4600,18244}'::integer[])))
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Rows Removed by Filter: 45
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Heap Blocks: exact=3D76322
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hit=3D495195
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 0: =C2=A0Heap Blocks: exact= =3D69229
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 1: =C2=A0Heap= Blocks: exact=3D67759
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker= 2: =C2=A0Heap Blocks: exact=3D69407
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0Worker 3: =C2=A0Heap Blocks: exact=3D68584
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 4: =C2=A0Heap Blocks: exact=3D68597
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Worker 5: =C2=A0Heap Blocks: e= xact=3D67828
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-> =C2=A0Bitm= ap Index Scan on job_stats_new_2026_05_job_board_id_job_reference_created_a= t_idx =C2=A0(cost=3D0.00..34356.49 rows=3D635582 width=3D0) (actual time=3D= 90.252..90.253 rows=3D610218.00 loops=3D1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Index Cond: ((job_board_id =3D 30875)= AND (created_at >=3D '2026-05-01 00:00:00'::timestamp without t= ime zone) AND (created_at <=3D '2026-05-31 23:59:59.999999'::tim= estamp without time zone))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0Index Searches: 1
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hit=3D7343
=C2=A0 =C2=A0-= > =C2=A0Hash =C2=A0(cost=3D1290.53..1290.53 rows=3D25173 width=3D8) (act= ual time=3D33.285..33.292 rows=3D25173.00 loops=3D1)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0Buckets: 32768 =C2=A0Batches: 1 =C2=A0Memory Usage: 1240kB=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Buffers: shared hit=3D10388
=C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0-> =C2=A0Seq Scan on employers =C2=A0(cost= =3D0.00..1290.53 rows=3D25173 width=3D8) (actual time=3D18.012..30.607 rows= =3D25173.00 loops=3D1)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0Buffers: shared hit=3D10388
=C2=A0Planning:
=C2=A0 =C2=A0Buffer= s: shared hit=3D1212
=C2=A0Planning Time: 2.535 ms
=C2=A0JIT:
=C2= =A0 =C2=A0Functions: 88
=C2=A0 =C2=A0Options: Inlining false, Optimizati= on false, Expressions true, Deforming true
=C2=A0 =C2=A0Timing: Generati= on 11.607 ms (Deform 5.619 ms), Inlining 0.000 ms, Optimization 7.214 ms, E= mission 90.846 ms, Total 109.668 ms
=C2=A0Execution Time: 1902.285 ms

--
<= div dir=3D"ltr">
Maxim Boguk
Senior Postgresql DBA

Phone= UA: +380 99 143 0000
Phone AU: +61=C2=A0 45 218 5678

<= /div>
--000000000000a8f591065349cff5--