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.94.2) (envelope-from ) id 1uUgHs-006xC0-2s for pgsql-performance@arkaria.postgresql.org; Thu, 26 Jun 2025 06:40:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uUgHq-008fzu-4j for pgsql-performance@arkaria.postgresql.org; Thu, 26 Jun 2025 06:40:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uUgHp-008fzj-OA for pgsql-performance@lists.postgresql.org; Thu, 26 Jun 2025 06:40:42 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uUgHn-004Af8-2Z for pgsql-performance@lists.postgresql.org; Thu, 26 Jun 2025 06:40:41 +0000 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-60c3aafae23so3669098a12.1 for ; Wed, 25 Jun 2025 23:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750920038; x=1751524838; darn=lists.postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=V2jhxNf8SeYUVGeWtpa36g6es0VxWXxa94yyfZ0RmOg=; b=Fjc3eHQz0t+g1vyBKf1zuL3plAdaaykzs5FILYXis+P6LOc2moyHue6c3SFt9dBVbl j0MPgtGn2k+8MhWmdummAgGTxzeJEQM1a0YPmpyH9SaUjltgG/+JcDnKNXudMrTpnRQR WogOtwQmf8CwO6JlISZ2R9RUJVM/R6vSWtxDtv0lHREEO1oSmN0UmyMxvbDCm3XwlHm1 o3CMz72+NNbiZyT6guEazj/ip9s/uEcIudAx3xn/A1ZGL03BD/C2/eE3MeqNc73salz+ mN44bHxYGiGnQ0qeotKqL25AjXz/CpPSnpKIi5hU5HM87zjzb2uhSukYGEnEQIR4J0+e iirQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750920038; x=1751524838; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=V2jhxNf8SeYUVGeWtpa36g6es0VxWXxa94yyfZ0RmOg=; b=rYvywJsVbtCcNBznegKtOeDrzLqiyBjBo3Vjdq/3U+Ohe58VhhQ/506QSlDXISqaeW dVc82GA1qpQN/TYVFRUW9LzULlNknmnzFjbQ3+4Y2bJViGkOmTQvCKb4SRbJLsv1/nA+ o/WRn5sHZiZuiv/z/dB5kkToMBVJxGmhlLe3/LAhJILupNotIoSFv5aEeqpy4Kudh0Nt GVGdOnh3wI6+syhlwF4588aPSDSEto/ji6u5DC8KwZ4Na6PP0bnFB+upIP5yUW42U6mB yUKNMS+BqwlO1jJFMqgkTB6nt/OXwWSKnkG5PaKDQtugTRfAG5Y7MoNdTs8Kn7/DiDnh zJdw== X-Forwarded-Encrypted: i=1; AJvYcCWU2naUpm7GA2aAcyKOWcgc04n96mo4teduZ2iW6nnU6OZdAcKowKo7P0IfWleeWRO90anK5vDO2NW7GRJWPWRHnw==@lists.postgresql.org X-Gm-Message-State: AOJu0YyFKRDSL1YjywwcZFKOmJ6xhSZIgNIcrFQ58U9lCEFEqkKcYf9H ZfQStAlWw2L8lBZBdF7pIPZd1pCkEDOJc0G5E7cFMGgGhD1l6eSdQVBeK6DpJw== X-Gm-Gg: ASbGncuUHQWcLOVJxIngvniZny6aojzl903RTnWiVzLFjok8NufFre+Q/kgnG6xocpe CdyL+jvl7r5qPHKo/RUCVTA8ckHcuvIYocM3glARxqmfQa2CLdaKoalquJENm9kLL0k1cr1DoFy spKFn6/9S8izfmlaLuDfiRe36MFlhn5rtx7ekTUjGZhjA8bfN+papv4ihnmy89zXKgfaWzuETVI AlRboQl7qbJktnFlrq2UhUuq0DqqAfYYUG0pwXlwHYhsnKkRUiOd5fZ7ADBgEnLSrNz4DhJX9A2 kq2kKtaovSUhlocpo0eZtY95o43+K7TfYwbguiASXpHhoaWZOXVN69qyPQZpXaEaD8LSuCR9pYu MI4GV98+U6EfJDLG2PxqTEYcLhGzQXFLR6f2LpcXcSBd5oldS3rWJQjew5OIAzmFoEJcycve5z7 kt32fcK0fAyCzwC6DibMuNSw== X-Google-Smtp-Source: AGHT+IETC2N75I+VyboM7iSZn0Of7APInBxifzas3C6cDJXcukH2KtEYsmS9dQmVvIzTezlKE5udWA== X-Received: by 2002:a17:907:3d0b:b0:ae0:a465:1c20 with SMTP id a640c23a62f3a-ae0d25ab3b8mr246224666b.14.1750920037744; Wed, 25 Jun 2025 23:40:37 -0700 (PDT) Received: from smtpclient.apple (2001-1c04-0681-7700-c8e5-498e-3967-d25c.cable.dynamic.v6.ziggo.nl. [2001:1c04:681:7700:c8e5:498e:3967:d25c]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae06c473598sm999118766b.60.2025.06.25.23.40.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jun 2025 23:40:37 -0700 (PDT) From: Frits Hoogland Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_8E2FF55B-20FC-4741-A7E5-929A88717683" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.600.51.1.1\)) Subject: Re: many sessions waiting DataFileRead and extend Date: Thu, 26 Jun 2025 08:40:26 +0200 In-Reply-To: Cc: Laurenz Albe , pgsql-performance@lists.postgresql.org To: James Pang References: <66879d8bd44148f2ef1dcde1eff056e6c671306e.camel@cybertec.at> X-Mailer: Apple Mail (2.3826.600.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_8E2FF55B-20FC-4741-A7E5-929A88717683 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Okay. So it's a situation that is reproducable. And like was mentioned, the system time (percentage) is very high. Is this a physical machine, or a virtual machine? The next thing to do, is use perf to record about 20 seconds or so = during a period of time when you see this behavior (perf record -g, = taking the backtrace with it). This records (samples) the backtraces of on cpu tasks, from which you = then can derive what they are doing, for which you should see lots of = tasks in kernel space, and what that is, using perf report. Frits Hoogland > On 26 Jun 2025, at 04:32, James Pang wrote: >=20 > thans for you suggestions, we have iowait from sar command too, copy = here, checking with infra team not found abnormal IO activities either. =20= > 02:00:01 PM CPU %usr %nice %sys %iowait %irq %soft = %steal %guest %gnice %idle > 02:00:03 PM all 15.92 0.00 43.02 0.65 0.76 2.56 = 0.00 0.00 0.00 37.09 > 02:00:03 PM 0 17.59 0.00 46.73 1.01 0.50 0.50 = 0.00 0.00 0.00 33.67 > 02:00:03 PM 1 9.50 0.00 61.50 0.50 0.50 = 1.00 0.00 0.00 0.00 27.00 > 02:00:03 PM 2 20.71 0.00 44.44 1.01 0.51 = 0.51 0.00 0.00 0.00 32.83 > 02:00:03 PM 3 14.00 0.00 51.50 2.00 1.00 1.00 = 0.00 0.00 0.00 30.50 > 02:00:03 PM 4 6.57 0.00 52.53 0.51 0.51 = 3.54 0.00 0.00 0.00 36.36 > 02:00:03 PM 5 10.20 0.00 49.49 1.02 1.53 = 0.00 0.00 0.00 0.00 37.76 > 02:00:03 PM 6 27.64 0.00 41.21 0.50 0.50 = 0.50 0.00 0.00 0.00 29.65 > 02:00:03 PM 7 9.05 0.00 50.75 0.50 1.01 0.50 = 0.00 0.00 0.00 38.19 > 02:00:03 PM 8 12.18 0.00 49.75 0.51 0.51 = 0.51 0.00 0.00 0.00 36.55 > 02:00:03 PM 9 13.00 0.00 9.50 0.50 1.50 = 15.50 0.00 0.00 0.00 60.00 > 02:00:03 PM 10 15.58 0.00 46.23 0.00 0.50 0.50 = 0.00 0.00 0.00 37.19 > 02:00:03 PM 11 20.71 0.00 10.10 0.00 1.01 = 14.14 0.00 0.00 0.00 54.04 > 02:00:03 PM 12 21.00 0.00 37.00 0.50 1.00 1.00 = 0.00 0.00 0.00 39.50 > 02:00:03 PM 13 13.57 0.00 45.73 1.01 1.01 1.01 = 0.00 0.00 0.00 37.69 > 02:00:03 PM 14 18.18 0.00 39.39 1.01 0.51 0.51 = 0.00 0.00 0.00 40.40 > 02:00:03 PM 15 14.00 0.00 49.50 0.50 0.50 3.50 = 0.00 0.00 0.00 32.00 > 02:00:03 PM 16 19.39 0.00 39.80 1.02 1.53 0.51 = 0.00 0.00 0.00 37.76 > 02:00:03 PM 17 16.75 0.00 45.18 1.52 1.02 2.54 = 0.00 0.00 0.00 32.99 > 02:00:03 PM 18 12.63 0.00 50.00 0.00 1.01 0.00 = 0.00 0.00 0.00 36.36 > 02:00:03 PM 19 5.56 0.00 82.32 0.00 0.00 0.00 = 0.00 0.00 0.00 12.12 > 02:00:03 PM 20 15.08 0.00 48.24 0.50 0.50 3.52 = 0.00 0.00 0.00 32.16 > 02:00:03 PM 21 17.68 0.00 9.09 0.51 1.52 13.64 = 0.00 0.00 0.00 57.58 > 02:00:03 PM 22 13.13 0.00 43.94 0.51 0.51 0.51 = 0.00 0.00 0.00 41.41 > 02:00:03 PM 23 14.07 0.00 42.71 0.50 0.50 0.50 = 0.00 0.00 0.00 41.71 > 02:00:03 PM 24 13.13 0.00 41.92 1.01 0.51 0.51 = 0.00 0.00 0.00 42.93 > 02:00:03 PM 25 16.58 0.00 47.74 0.50 1.01 0.50 = 0.00 0.00 0.00 33.67 > 02:00:03 PM 26 16.58 0.00 46.73 0.50 1.01 0.50 = 0.00 0.00 0.00 34.67 > 02:00:03 PM 27 45.50 0.00 54.50 0.00 0.00 0.00 = 0.00 0.00 0.00 0.00 > 02:00:03 PM 28 6.06 0.00 32.32 0.00 0.51 13.13 = 0.00 0.00 0.00 47.98 > 02:00:03 PM 29 13.93 0.00 44.78 1.00 1.00 0.50 = 0.00 0.00 0.00 38.81 > 02:00:03 PM 30 11.56 0.00 57.79 0.00 0.50 1.01 = 0.00 0.00 0.00 29.15 > 02:00:03 PM 31 33.85 0.00 9.23 0.51 1.54 0.51 = 0.00 0.00 0.00 54.36 > 02:00:03 PM 32 30.15 0.00 41.71 0.50 0.50 1.51 = 0.00 0.00 0.00 25.63 >=20 > Thanks, >=20 > James=20 >=20 > Frits Hoogland > =E6=96=BC 2025=E5=B9=B46=E6=9C=8825=E6=97= =A5=E9=80=B1=E4=B8=89 =E4=B8=8B=E5=8D=8810:27=E5=AF=AB=E9=81=93=EF=BC=9A >>=20 >>=20 >> > On 25 Jun 2025, at 07:59, Laurenz Albe > wrote: >> >=20 >> > On Wed, 2025-06-25 at 11:15 +0800, James Pang wrote: >> >> pgv14, RHEL8, xfs , we suddenly see tens of sessions waiting on = "DataFileRead" and >> >> "extend", it last about 2 seconds(based on pg_stat_activity query) = , during the >> >> waiting time, "%sys" cpu increased to 80% , but from "iostat" , no = high iops and >> >> io read/write latency increased either. >> >=20 >> > Run "sar -P all 1" and see if "%iowait" is high. >> I would (strongly) advise against the use of iowait as an indicator. = It is a kernel approximation of time spent in IO from which cannot be = use used in any sensible way other than possibly you're doing IO. >> First of all, iowait is not a kernel state, and therefore it's taken = from idle. This means that if there is no, or too little, idle time, = iowait that should be there is gone. >> Second, the calculation to transfer idle time to iowait is done for = synchronous IO calls only. Which currently is not a problem for postgres = because it uses exactly that, but in the future it might. >> Very roughly put, what the kernel does is keep a counter of tasks = currently in certain system IO calls, and then try to express that using = iowait. The time in IO wait can't be used calculate any IO facts. >>=20 >> In that sense, it puts it in the same area as the load figure: = indicative, but mostly useless because it doesn't give you any facts = about what it is expressing. >> >=20 >> > Check if you have transparent hugepages enabled: >> >=20 >> > cat /sys/kernel/mm/transparent_hugepage/enabled >> >=20 >> > If they are enabled, disable them and see if it makes a difference. >> >=20 >> > I am only guessing here. >> Absolutely. Anything that is using signficant amounts of memory and = is not created to take advantage of transparent hugepages will probably = experience more downsides from THP than it helps. >> >=20 >> >> many sessions were running same "DELETE FROM xxxx" in parallel = waiting on "extend" >> >> and "DataFileRead", there are triggers in this table "After = delete" to insert/delete >> >> other tables in the tigger.=20 >> >=20 >> > One thing that almost certainly would improve your situation is to = run fewer >> > concurrent statements, for example by using a reasonably sized = connection pool. >> This is true if the limits of the IO device, or anything towards to = IO device or devices are hit. >> And in general, high "%sys", alias lots of time spent in kernel mode = alias system time indicates lots of time spent in system calls, which is = what the read and write calls in postgres are. >> Therefore these figures suggest blocking for IO, for which Laurenz' = advise to lower the amount of concurrent sessions doing IO in general = makes sense. >> A more nuanced analysis: if IO requests get queued, these will wait = in 'D' state in linux, which by definition is off cpu, and thus do not = spent cpu (system/kernel) time. >>=20 >> What sounds suspicious is that you indicate you indicate there is you = see no signficant change in the amount of IO in iostat. >>=20 >> In order to understand this, you will have to first carefully find = the actual IO physical IO devices that you are using for postgres IO. >> In current linux this can be tricky, depending on how the hardware or = virtual machine looks like, and how the disks are arranged in linux. >> What you need to determine is which actual disk devices are used, and = what their limits are.=20 >> Limits for any disk are IOPS (operations per second) and MBPS = (megabytes per second -> bandwdith). >>=20 >> There is an additional thing to realize, which makes this really = tricky: postgres for common IO uses buffered IO. >> Buffered IO means any read or write will use the linux buffercache, = and read or writes can be served from the buffercache if possible. >>=20 >> So in your case, if you managed to make the database perform = identical read or write requests, this could result in a difference of = amounts of read and write IOs served from the cache, which can make an = enormous amounts of difference for how fast these requests are served. = If somehow you managed to make the operating system choose to use the = physical IO path, you will see significant amounts time spent on that, = which will have IO related wait events. >>=20 >> Not a simple answer, but this is how it works. >>=20 >> So I would suggest checking the difference between the situation of = when it's doing the same which is considered well performing versus = badly performing. >>=20 >>=20 >> >=20 >> > Yours, >> > Laurenz Albe >> >=20 >> >=20 >>=20 --Apple-Mail=_8E2FF55B-20FC-4741-A7E5-929A88717683 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Okay. So it's = a situation that is reproducable.
And like was mentioned, the system = time (percentage) is very high.
Is this a physical machine, or = a virtual machine?

The next thing to do, is use = perf to record about 20 seconds or so during a period of time when you = see this behavior (perf record -g, taking the backtrace with = it).
This records (samples) the backtraces of on cpu tasks, = from which you then can derive what they are doing, for which you should = see lots of tasks in kernel space, and what that is, using perf = report.

Frits = Hoogland




On 26 Jun 2025, at 04:32, James = Pang <jamespang886@gmail.com> wrote:

thans for you = suggestions, we have iowait from sar command too, copy here, checking = with infra team not found abnormal IO activities = either.  
02:00:01 PM  CPU    %usr   = %nice    %sys %iowait    %irq   %soft =  %steal  %guest  %gnice   %idle
02:00:03 PM =  all         15.92    0.00 =   43.02    0.65    0.76    2.56 =    0.00    0.00    0.00   = 37.09
02:00:03 PM    0        =  17.59    0.00   46.73    1.01   =  0.50    0.50    0.00    0.00   =  0.00   33.67
02:00:03 PM    1    =       9.50     0.00   61.50   =  0.50    0.50    1.00    0.00   =  0.00    0.00   27.00
02:00:03 PM   =  2          20.71    0.00   = 44.44    1.01    0.51    0.51   =  0.00    0.00    0.00   32.83
02:00:03 = PM    3         14.00   =  0.00   51.50    2.00    1.00   =  1.00    0.00    0.00    0.00   = 30.50
02:00:03 PM    4          = 6.57     0.00   52.53    0.51   =  0.51    3.54    0.00    0.00   =  0.00   36.36
02:00:03 PM    5    =       10.20    0.00   49.49   =  1.02    1.53    0.00    0.00   =  0.00    0.00   37.76
02:00:03 PM   =  6          27.64    0.00   = 41.21    0.50    0.50    0.50   =  0.00    0.00    0.00   29.65
02:00:03 = PM    7          9.05   =  0.00   50.75    0.50    1.01   =  0.50    0.00    0.00    0.00   = 38.19
02:00:03 PM    8          = 12.18    0.00   49.75    0.51    0.51 =    0.51    0.00    0.00    0.00 =   36.55
02:00:03 PM    9        =   13.00    0.00    9.50    0.50 =    1.50   15.50    0.00    0.00 =    0.00   60.00
02:00:03 PM   10    =      15.58    0.00   46.23   =  0.00    0.50    0.50    0.00   =  0.00    0.00   37.19
02:00:03 PM   11  =         20.71    0.00   10.10   =  0.00    1.01   14.14    0.00   =  0.00    0.00   54.04
02:00:03 PM   12  =        21.00    0.00   37.00   =  0.50    1.00    1.00    0.00   =  0.00    0.00   39.50
02:00:03 PM   13  =        13.57    0.00   45.73   =  1.01    1.01    1.01    0.00   =  0.00    0.00   37.69
02:00:03 PM   14 =   18.18    0.00   39.39    1.01   =  0.51    0.51    0.00    0.00   =  0.00   40.40
02:00:03 PM   15   14.00   =  0.00   49.50    0.50    0.50   =  3.50    0.00    0.00    0.00   = 32.00
02:00:03 PM   16   19.39    0.00   = 39.80    1.02    1.53    0.51   =  0.00    0.00    0.00   37.76
02:00:03 = PM   17   16.75    0.00   45.18   =  1.52    1.02    2.54    0.00   =  0.00    0.00   32.99
02:00:03 PM   18 =   12.63    0.00   50.00    0.00   =  1.01    0.00    0.00    0.00   =  0.00   36.36
02:00:03 PM   19    5.56 =    0.00   82.32    0.00    0.00 =    0.00    0.00    0.00    0.00 =   12.12
02:00:03 PM   20   15.08    0.00 =   48.24    0.50    0.50    3.52 =    0.00    0.00    0.00   = 32.16
02:00:03 PM   21   17.68    0.00   =  9.09    0.51    1.52   13.64   =  0.00    0.00    0.00   57.58
02:00:03 = PM   22   13.13    0.00   43.94   =  0.51    0.51    0.51    0.00   =  0.00    0.00   41.41
02:00:03 PM   23 =   14.07    0.00   42.71    0.50   =  0.50    0.50    0.00    0.00   =  0.00   41.71
02:00:03 PM   24   13.13   =  0.00   41.92    1.01    0.51   =  0.51    0.00    0.00    0.00   = 42.93
02:00:03 PM   25   16.58    0.00   = 47.74    0.50    1.01    0.50   =  0.00    0.00    0.00   33.67
02:00:03 = PM   26   16.58    0.00   46.73   =  0.50    1.01    0.50    0.00   =  0.00    0.00   34.67
02:00:03 PM   27 =   45.50    0.00   54.50    0.00   =  0.00    0.00    0.00    0.00   =  0.00    0.00
02:00:03 PM   28    6.06 =    0.00   32.32    0.00    0.51 =   13.13    0.00    0.00    0.00 =   47.98
02:00:03 PM   29   13.93    0.00 =   44.78    1.00    1.00    0.50 =    0.00    0.00    0.00   = 38.81
02:00:03 PM   30   11.56    0.00   = 57.79    0.00    0.50    1.01   =  0.00    0.00    0.00   29.15
02:00:03 = PM   31   33.85    0.00    9.23   =  0.51    1.54    0.51    0.00   =  0.00    0.00   54.36
02:00:03 PM   32 =   30.15    0.00   41.71    0.50   =  0.50    1.51    0.00    0.00   =  0.00   = 25.63

Thanks,

James&= nbsp;

Frits = Hoogland <frits.hoogland@gmail.com> = =E6=96=BC 2025=E5=B9=B46=E6=9C=8825=E6=97=A5=E9=80=B1=E4=B8=89 = =E4=B8=8B=E5=8D=8810:27=E5=AF=AB=E9=81=93=EF=BC=9A


> On 25 Jun 2025, at 07:59, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
>
> On Wed, 2025-06-25 at 11:15 +0800, James Pang wrote:
>> pgv14, RHEL8, xfs , we suddenly see tens of sessions waiting on = "DataFileRead" and
>> "extend", it last about 2 seconds(based on pg_stat_activity = query) , during the
>> waiting time, "%sys" cpu increased to 80% , but from "iostat" , = no high iops and
>> io read/write latency increased either.
>
> Run "sar -P all 1" and see if "%iowait" is high.
I would (strongly) advise against the use of iowait as an indicator. It = is a kernel approximation of time spent in IO from which cannot be use = used in any sensible way other than possibly you're doing IO.
First of all, iowait is not a kernel state, and therefore it's taken = from idle. This means that if there is no, or too little, idle time, = iowait that should be there is gone.
Second, the calculation to transfer idle time to iowait is done for = synchronous IO calls only. Which currently is not a problem for postgres = because it uses exactly that, but in the future it might.
Very roughly put, what the kernel does is keep a counter of tasks = currently in certain system IO calls, and then try to express that using = iowait. The time in IO wait can't be used calculate any IO facts.

In that sense, it puts it in the same area as the load figure: = indicative, but mostly useless because it doesn't give you any facts = about what it is expressing.
>
> Check if you have transparent hugepages enabled:
>
>  cat /sys/kernel/mm/transparent_hugepage/enabled
>
> If they are enabled, disable them and see if it makes a = difference.
>
> I am only guessing here.
Absolutely. Anything that is using signficant amounts of memory and is = not created to take advantage of transparent hugepages will probably = experience more downsides from THP than it helps.
>
>> many sessions were running same "DELETE FROM xxxx" in parallel = waiting on "extend"
>> and "DataFileRead", there are triggers in this table "After = delete" to insert/delete
>> other tables in the tigger.
>
> One thing that almost certainly would improve your situation is to = run fewer
> concurrent statements, for example by using a reasonably sized = connection pool.
This is true if the limits of the IO device, or anything towards to IO = device or devices are hit.
And in general, high "%sys", alias lots of time spent in kernel mode = alias system time indicates lots of time spent in system calls, which is = what the read and write calls in postgres are.
Therefore these figures suggest blocking for IO, for which Laurenz' = advise to lower the amount of concurrent sessions doing IO in general = makes sense.
A more nuanced analysis: if IO requests get queued, these will wait in = 'D' state in linux, which by definition is off cpu, and thus do not = spent cpu (system/kernel) time.

What sounds suspicious is that you indicate you indicate there is you = see no signficant change in the amount of IO in iostat.

In order to understand this, you will have to first carefully find the = actual IO physical IO devices that you are using for postgres IO.
In current linux this can be tricky, depending on how the hardware or = virtual machine looks like, and how the disks are arranged in linux.
What you need to determine is which actual disk devices are used, and = what their limits are.
Limits for any disk are IOPS (operations per second) and MBPS (megabytes = per second -> bandwdith).

There is an additional thing to realize, which makes this really tricky: = postgres for common IO uses buffered IO.
Buffered IO means any read or write will use the linux buffercache, and = read or writes can be served from the buffercache if possible.

So in your case, if you managed to make the database perform identical = read or write requests, this could result in a difference of amounts of = read and write IOs served from the cache, which can make an enormous = amounts of difference for how fast these requests are served. If somehow = you managed to make the operating system choose to use the physical IO = path, you will see significant amounts time spent on that, which will = have IO related wait events.

Not a simple answer, but this is how it works.

So I would suggest checking the difference between the situation of when = it's doing the same which is considered well performing versus badly = performing.


>
> Yours,
> Laurenz Albe
>
>


= --Apple-Mail=_8E2FF55B-20FC-4741-A7E5-929A88717683--