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 1t0e7X-00CUi0-Bd for pgsql-general@arkaria.postgresql.org; Tue, 15 Oct 2024 09:45:39 +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 1t0e7V-005Fcq-DE for pgsql-general@arkaria.postgresql.org; Tue, 15 Oct 2024 09:45:37 +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 1t0e7V-005Fci-1y for pgsql-general@lists.postgresql.org; Tue, 15 Oct 2024 09:45:37 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t0e7S-001A0B-Is for pgsql-general@postgresql.org; Tue, 15 Oct 2024 09:45:36 +0000 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5389917ef34so5674941e87.2 for ; Tue, 15 Oct 2024 02:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728985533; x=1729590333; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0a3+sa1zlgN2kHqLgugaEhYrgSRdEm28Bti9GfCS39I=; b=nStT+7UveAkf8QjxaFEBBvMe6iEi5ev90PzhCYB2Szd7iIv+aMIOE70OFQSjs0+Mx9 +7wrcAuKBlrTLTKKVp7LW19OmvRrwT08AEukClA+ja24pCWjc2SECxoBoKkU5UO5NIS6 xwALSV50yJAop9kO2dqe9IL5scn5ZK//18VvyzuC/XadAp7zOSeuGMpG1Rq6g5qkPGL5 Me5D+u2LEc9Kl6TP7wmTe+S8wonX/Ml6PQ2IqlfLjhxmsH72GHjF4mXN/R7pkO6dM9ro Gz86bm5LG5qbL7n7mpNB0EgKvLdbDUvhU+6xAuRVGExme5e5dIS6SnTgcFfe7h4V5Xhr ThJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728985533; x=1729590333; h=cc: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=0a3+sa1zlgN2kHqLgugaEhYrgSRdEm28Bti9GfCS39I=; b=EOqV3RLfmxUOPdumg8Y3R66lmVntgLaCk1JFAQnpnrEZjqsnN0mxfyUAJbpPLtce+W r2JHmd9wTgz5m4Ct2EpMvEoOOUzoO/NauxyIrHPfgIlhxD6/TQYEM6ZojlAFmyR9hjmq bfCdV4+qGl5JDBYI+/pI5JxTuI8NXZ+hNkkOvn2V6Cyt0mit6ZS5VAF67O+0djHkMPBV ZXxcnJYxNUo4h2Dbs8R15c4Tmb8lNliD9mFWPcdv8XNhq/TptFNLmnnZszxbItEaIke3 TPdhrxDvLZ+c5AB3APMR13AhaEz9XVoJPVWV+GDEqijaUTmOFoxhbxWfTXiT0mXlAOg6 pvDg== X-Gm-Message-State: AOJu0Ywt8MWoGL0JnHdDo8H/54Zeb/JaCo2zGC1ytKr5oSuRHaIW0wpl 7BbQ19SNM83zRvtgPuBr9WlZhP1jMnz2tk6jjVvSoOaXd4hRN97ZnjfVns+wbxF5OB29G27G5S2 sNFINmkleTVZvSwyYWazKhfprKbQ= X-Google-Smtp-Source: AGHT+IGVQ1fwvee/r8lEgig9gQnUM62xPRuJALyp7zqXh5YePn7/rtrb6zLvOXhn8eKNR7LF1XWlEgofSfXP49TTKR0= X-Received: by 2002:a05:6512:23a9:b0:539:9594:b226 with SMTP id 2adb3069b0e04-539e5620d75mr4729046e87.34.1728985532479; Tue, 15 Oct 2024 02:45:32 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Tue, 15 Oct 2024 22:45:19 +1300 Message-ID: Subject: Re: Inefficient use of index scan on 2nd column of composite index during concurrent activity To: Durgamahesh Manne Cc: PostgreSQL mailing lists , Greg Sabino Mullane Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 12 Oct 2024 at 02:28, Durgamahesh Manne wrote: > 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 = '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 ? It sounds like you might be asking about something we call "index skip scans". Currently, PostgreSQL does not support these, however there is work being done to add support and that might arrive in PG18. There is some information about a possible workaround in [1] which may be of use to you. David [1] https://wiki.postgresql.org/wiki/Loose_indexscan