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 1szFhJ-0054st-RU for pgsql-general@arkaria.postgresql.org; Fri, 11 Oct 2024 13:28:49 +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 1szFhH-004P4d-KJ for pgsql-general@arkaria.postgresql.org; Fri, 11 Oct 2024 13:28:47 +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 1szFhH-004P4U-7z for pgsql-general@lists.postgresql.org; Fri, 11 Oct 2024 13:28:47 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1szFhA-000WOg-AA for pgsql-general@postgresql.org; Fri, 11 Oct 2024 13:28:46 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a99b1f43aceso212247866b.0 for ; Fri, 11 Oct 2024 06:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728653320; x=1729258120; darn=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=PvH1LlZP+OiJYqQY91VEGMeqcsUip+TubknwAnOEwLQ=; b=Ztrfy5TMuhwHVWaIZbhR2P7UWJ1b0mtlbF2LWDvKGKDYMM0h2g5b8oepdS12Z/sC+7 WeTfb4a4yHjO84DgEnJNtbRPyheAopTjQf9TZrmfwjzfIHWwahwaHBm18weuj1dbROFU RylQesfOk0a5baCMoyt/S7nFdh2jEtxDE8uHosAjOPRUlqxPxrhHN+VaizrO+NY4+V6W iJ3o5iaPIXndTkkVHlWPGBlTO6tKIY9mi4TuBEkoFWgWiHxszCNbW7w4GtzlhfzsLawE eCAIXCoe4VcQXU/SVsmyJTkLQ+CxCYpkmqgcn1Bw1adAsW/Wb3hfwr80MtHgBKXf+RQZ ReXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728653320; x=1729258120; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PvH1LlZP+OiJYqQY91VEGMeqcsUip+TubknwAnOEwLQ=; b=KUqtwy2m7A1XLkI3SqWlhmnmiodi2pnXFn2ksYqauTE/1z5yvvxMM+0zl34MUnmMdU ILp0l3MSPwtFfvfmwhNpsvIqFMIjwlTelIrOORbTxzRHpSpl7y2Bllcxg4yjbVIVNyn3 CGN8FEB8/DQ8rzxYVD0b9DudFuoAqGD3iuwfTK55dosO74cn/nlrMtFOvs+9jd3ALj6x stTLcrjuWrav7PEYbqqi+wUpMI8sLzcIhplBTw2Yw+jJLHKAWullwRDUWMm/3A1qT+LX T4CzqF2cNwSlKTLJeqV0ioXRpdKFSRMkXebIDQV1bSho3nVPcNHtlaA7tmlFho5qW2i/ hQ9w== X-Gm-Message-State: AOJu0YxvZL7bwMRqViIbIJt/lR67/fSdj4OtiA6aY9pMrhBVTYiNASf0 y6/hN4XzenijIXLCQ3AuDl+/VoCNlRjFNjZWRzG6jJjERdy9Jeeztfzoc6I7jDhRiY6fI8tQIbD H9vfW5LmlH/PFymHToz+0cHXLxFZv4mRm5bw= X-Google-Smtp-Source: AGHT+IExfZl27JtBU8v0ANHRa1IWVAkeL9rzvPpJ27xIIBh0dijo+QBvL28qxjkKE7tOhGxKKThbuu469/NW9EdkFLk= X-Received: by 2002:a17:907:efc8:b0:a99:50e2:40ab with SMTP id a640c23a62f3a-a99b8867265mr243218666b.20.1728653320048; Fri, 11 Oct 2024 06:28:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Durgamahesh Manne Date: Fri, 11 Oct 2024 19:01:50 +0530 Message-ID: Subject: Fwd: Inefficient use of index scan on 2nd column of composite index during concurrent activity To: PostgreSQL mailing lists , Greg Sabino Mullane Content-Type: multipart/alternative; boundary="00000000000014db490624337707" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000014db490624337707 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable ---------- Forwarded message --------- From: Durgamahesh Manne Date: Mon, Oct 7, 2024 at 10:01=E2=80=AFAM Subject: Inefficient use of index scan on 2nd column of composite index during concurrent activity To: Hi team Second column of composite index not in use effectively with index scan when using second column at where clause I have composite index on (placedon,id) of test When quering select * from test where id =3D '4234'; Value of id changes and during concurrent activity and cpu utilization increased toomuch that i have observed which means query plan changed why I could see index scan with explain for it Is there any way to keep index scan for it during even on concurrency rather than seperate index on second column of composite index ? Hope everyone understand this Regards, Durga Mahesh Hi Greg you mentioned that below (please start a new thread in the future rather than replying to an existing one) You cannot query on b and use an index on (a,b) as you observed. However, you can have two indexes: index1(a) index2(b) Postgres will be able to combine those when needed in the case where your WHERE clause needs to filter by both columns. So then you no longer need the two-column index. Hi Greg , Here not using composite index on ordinary table. Composite index that i use on partitioned table is mandatory for use to replicate data to target using pglogical (sorry this is not mentioned earlier) composite key (placedon,id) In concurrent mode if i use id at where clause then query plan for that id column changes How to mitigate it rather than use seperate index for id to continue without change in query plan (index scan) during concurrent activity I hope you understand this Regards, Durga Mahesh Cheers, Greg --00000000000014db490624337707 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable



---------- Forwarded message ---------
From: Durgamahesh Manne <maheshpost= gres9@gmail.com>
Date: Mon, Oct 7, 2024 at 10:01=E2=80=AFA= M
Subject: Inefficient use of index scan on 2nd column of composite inde= x during concurrent activity
To: <pgsql-in-general@postgresql.org>


<= div dir=3D"auto">Hi team=C2=A0

Second column of composite index not in use effectively with index scan=C2= =A0 when using second column at where clause

I have composite index on (placedon,id) of test=C2=A0<= /div>
When quering=C2=A0 select * from test where id =3D &= #39;4234';
Value of id changes and during concur= rent activity and cpu utilization increased toomuch=C2=A0 that i have obser= ved which means query plan changed why

I could see index scan with explain for it=C2=A0

Is there any way to keep index scan= for it during even on concurrency rather than seperate index on second col= umn of composite index ?

Hope everyone understand this=C2=A0

Regards,
Durga Mahesh=C2=A0


Hi Greg= =C2=A0

you mentioned tha= t below

(please start a new thread in the future rat= her than replying to an existing one)

You cannot query o= n b and use an index on (a,b) as you observed. However, you can have two in= dexes:

index1(a)
index2(b)
Postgres will be able to combine those when needed in the case = where your WHERE clause needs to filter by both columns. So then you no lon= ger need the two-column index.



=
Hi Greg ,

Here not using composite inde= x on ordinary table.
Composite index that i use on partitioned ta= ble is mandatory for use to replicate data to target using pglogical=C2=A0 = (sorry this is not mentioned earlier)

composite ke= y (placedon,id)=C2=A0
In concurrent mode if i use id at where cla= use then query plan for that id column changes=C2=A0

How to mitigate it rather than use seperate index for id to continue wit= hout change in query plan (index scan) during concurrent activity=C2=A0

I hope you understand this=C2=A0

=
Regards,
Durga Mahesh=C2=A0





Cheers,
Greg=
--00000000000014db490624337707--