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 1szFmk-0055WX-Dn for pgsql-general@arkaria.postgresql.org; Fri, 11 Oct 2024 13:34:26 +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 1szFmh-004Y7W-Pl for pgsql-general@arkaria.postgresql.org; Fri, 11 Oct 2024 13:34:24 +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.94.2) (envelope-from ) id 1szFmh-004Y7O-Ax for pgsql-general@lists.postgresql.org; Fri, 11 Oct 2024 13:34:23 +0000 Received: from mail-ej1-x630.google.com ([2a00:1450:4864:20::630]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1szFmf-000NCe-3e for pgsql-general@lists.postgresql.org; Fri, 11 Oct 2024 13:34:22 +0000 Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a86e9db75b9so334412666b.1 for ; Fri, 11 Oct 2024 06:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728653659; x=1729258459; darn=lists.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=MdxQ4TivBkOqSGGB89lnFkIxKI2a/sVvJsbM4YiTTMI=; b=Z55tOvnOlxlWilff3ClXtlZonnykvXzJOlaNKOBcXgA1DjDUf1Xj7PLn99JPsIpfOt sCEVGTPAJPZob2PsOg2kDrJXm7/FtH4jH8y2+iw1eI3tw5u0N/LvJWC4Tyq+Y/Qc9Lzx me28pI65Eix6uedQ1nntaKw5U9XdBOOlS+P5kouFPMcIH7rUApF9K3GASqPlvRgosdG+ Hayf8YhMth4NrZnLL+7A5RbUUpKdJCJpOrnqKbEUbka4zDE/fsRc+YfhOFVfTdKNKE1Z e1TtGS8Src3+ZlIWiOXoIlOTDeCLYXHTf9YVa1o42Uxx2J6sA1yBDqd8Mv71p04NBK0X H7rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728653659; x=1729258459; 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=MdxQ4TivBkOqSGGB89lnFkIxKI2a/sVvJsbM4YiTTMI=; b=YFyuFN7XPeUDaIfjYpXuluc6agfpFPQ6iiLvzQL2rZ17FfaFxY7Th1sVox3Mq2VtZ8 mUiQq131U+q2p2WGwA/pIPOlYgL33dsUQ95e6s/NZ4AYK+whbN+IQwapqu2p0wDX9HIH X3ebhloqRk6OodumM9HKhrLlipF4WMyuNYdRTg752TQlaVxDgyyM/Bh1/YbB+W4fHTPd f9dNW5e5bi8YDclWJO2uKJbZ5Bw2YowVdCmI7WxR/bqsY6PrcT0RbV+eJ/EBqRjDnyYk QMC0MS0obYXqeNxEJYVUloYaMZbIOYUvC81hDnk1CqeKepJnF9pRBXpC0X9Tz/dH+/UY 5gvw== X-Forwarded-Encrypted: i=1; AJvYcCXGpx2EDxNixRw8DV6cbPiNMpT3GNKrk7WSeEGd9lZf0VzR41T02k75LADA9M+zlAMKwKIY0LT5r5U0AEWG@lists.postgresql.org X-Gm-Message-State: AOJu0Yx+XO5V1KIVzLBikrIeSHpOSFVcpV27zbJD/OO4cGI1bqdODL9g EaYs/LMs1fRKjfUSe6UMF0IOe9c+UL5sf8Q6ewCKFjKVzO1SGMW3sQz4pTjwdxiok7rC0IdoWJc NfKq+l0MZonW8HjBPk1JBSot6fos= X-Google-Smtp-Source: AGHT+IHyhVikIrmJ/pfF5Zf5K/K0jnuNSu3DZyIqU9175KvZK1dgEZKEZm0oTCQnoYUTYXiJrYLfg3vOwxTLke7jLpM= X-Received: by 2002:a17:907:7295:b0:a99:7bc0:bca2 with SMTP id a640c23a62f3a-a99b93aaeb8mr218277166b.8.1728653659269; Fri, 11 Oct 2024 06:34:19 -0700 (PDT) MIME-Version: 1.0 References: <88e5c335-c70e-4973-9b71-6c12e251e5b7@ewie.name> In-Reply-To: From: Durgamahesh Manne Date: Fri, 11 Oct 2024 19:07:30 +0530 Message-ID: Subject: Re: Question on indexes To: Greg Sabino Mullane Cc: sud , Erik Wienhold , xof@thebuild.com, pgsql-general Content-Type: multipart/alternative; boundary="0000000000004cf3f60624338b44" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004cf3f60624338b44 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Oct 11, 2024 at 6:18=E2=80=AFPM Greg Sabino Mullane wrote: > (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. > > Cheers, > Greg > Hi greg Mail sent you with a new thread. composite key is on partitioned table Regards, Durga Mahesh --0000000000004cf3f60624338b44 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Oct 11, 2024 at 6:18=E2=80=AF= PM Greg Sabino Mullane <htamfids@g= mail.com> wrote:
(please start a new thread in the future rather th= an replying to an existing one)

You cannot query on b an= d 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 ne= ed the two-column index.

Cheers,
Greg

=C2=A0
Hi gr= eg=C2=A0

Mail sent you with a new thread. composit= e key is on partitioned table=C2=A0

Regards,
=
Durga Mahesh=C2=A0=C2=A0
--0000000000004cf3f60624338b44--