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 1vrzjn-00GxPq-2h for pgsql-general@arkaria.postgresql.org; Mon, 16 Feb 2026 14:38:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vrzjm-002kr1-0b for pgsql-general@arkaria.postgresql.org; Mon, 16 Feb 2026 14:38:10 +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 1vrzjl-002kqt-2h for pgsql-general@lists.postgresql.org; Mon, 16 Feb 2026 14:38:10 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vrzjj-00000000u18-1mp6 for pgsql-general@lists.postgresql.org; Mon, 16 Feb 2026 14:38:08 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4806bf39419so37826175e9.1 for ; Mon, 16 Feb 2026 06:38:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1771252687; x=1771857487; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=uTsYw9yrNYoEvQnqjMAR3tTQ3PReZ5CU5nRhYAQHlR0=; b=VpUC84hhS/EjJ+cAkDRxehnDtf+Inmsmn0ay7nhety8UN4EyDN90A/zs+gcvAYm4Pv Mj0c6qJy1PDS6+j+41rwo6lXTXn5ZYxPQRDt6zQ/s4rMXVVK84oohnnUvluyuFU1huaT qd9z4BPqQ81FudcDly/TDXEp9HGfJ4/PcSaIWysZRTg4aKCPYmigatPs6NtmHJL3yDdb V2Jy5nePCuWWNr8czc8e0GjwUkSUOZXD07qM/GeRDfIqztzV6tIdONZUIsMVVLHFasRn 6tMpTkspOS1HWdA3GO7eInEYiUjH+96kh8VM9iraD0bTitQj8DAunJnth5hOfiDJhJOc Iggw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771252687; x=1771857487; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uTsYw9yrNYoEvQnqjMAR3tTQ3PReZ5CU5nRhYAQHlR0=; b=hek0LDzJTeR31zI2po8sz5V0E5rR5ple2ZMvOLhcMNxlDCHs9QezmiSsK7DIU9LNyR ffujVgIINoiAFx++Y+lGZ3hZdsCIBjwxrMZQS8AdaPTcdcAybsgBzkItt0RU49EiaFVN IrvOIG7miK4wckr2iATuRHpEmPHJkk6/i3fV3F+sD9vlDJGVg2tiL/jiSG9nlcAiqrku 7e0xzByY9+TNwbI0MgZFh0JqAeOrpnXUk4wWtZvqi756NzqDQYP0FAYXqrvgxIR9Vw87 uZsgh5Zmv5fdhXUYaD95alRaCRbckgrJ02oZ59lUbPEEECdHRUdq1CSuZQk6t4bf7kjS OVCw== X-Forwarded-Encrypted: i=1; AJvYcCVJGMln5Ule6DaIBLiVFFC/T1GIjbevGIQWGU8KkBWPYFuakpD29hoEdJZ1MKT3Nh3v8agoBVO1xnnQ0dJC@lists.postgresql.org X-Gm-Message-State: AOJu0YzWqBr7j0yT4LB76vd7JJFq14Vkg4ygKfzxwjYBvQeMoynBRL40 TxhOsTdWVVCF4PJp9F/CMewaaw5PoD9tCQpIgVB9Pai1oY7HD+R9QHyRiklTIfKQ6vs= X-Gm-Gg: AZuq6aIYLsqSz+qnh1UCenR6vHBWfDEHaDnLFBTv+KiurJ8UnZlUZSE7i4wxshpeJe5 4uFlYhpWhZcfWYhNytRI53mqDeUXVZQBwUrcM9B9gn9izCMM9oBpTdpbwqqo/psTnyVfeySAiHH I6nUAJAYf5QuYN/KnfX96eAyeJrR9FP0Mtqpc5DGBdbgLZP+4f6E/TWqNnnMb/oIYngtyg7RFET PTAxtzFrjdL9Enqvt1YzpdMkTN6V51/AncqRWK289Q6hk5/ReU05Yx77nWR1+34I9zUnuZK2ZaS pUdTjsc2R0Y1ZpLRacItxI6dUWOF6YRajcL2rY6pPBi3SXhUC1BmpEjbdF5vEHNzhc/X9VWagpB /Z2lZTfiDx9FcLZKS3PUb6UJi8ZM8y00X+ZoNom+g/E2cre2ngeUJUSsPsMK96O5Hx5z19PG0+4 Kz14Mx1Y0NCnCcE/y1vqXF7AYtId2IaCDxg03X8fRzUXzt+5VDHhN9 X-Received: by 2002:a05:600c:4eca:b0:480:1c1c:47d6 with SMTP id 5b1f17b1804b1-48378d6a4c5mr167651865e9.6.1771252686644; Mon, 16 Feb 2026 06:38:06 -0800 (PST) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:260:43f:6be4:fbbc:e040:7a7e]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48370a694d3sm86652545e9.10.2026.02.16.06.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Feb 2026 06:38:06 -0800 (PST) Message-ID: Subject: Re: Question on execution plan and suitable index From: Laurenz Albe To: yudhi s Cc: Ron Johnson , Adrian Klaver , Nisarg Patel , pgsql-general Date: Mon, 16 Feb 2026 15:38:05 +0100 In-Reply-To: References: <818d0359d8b629a80b55b2e068dab958fc8e0a2a.camel@cybertec.at> <2fa62200cf92dc03dff20f8a42e45bb30fc40f35.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2026-02-16 at 17:52 +0530, yudhi s wrote: > Regarding the composite index on (request_id, event_comment_text, created= _at) for > table event_audit_log, is there any advice, which we should follow for ke= eping > "date column"(like column "Created_at" here) in the indexing order (apart= from > the frequency of usage in the query)? The rule is to first have all columns that are compared with equality, then= the others, starting with the most selective one. Based on the condition, I gu= essed that that wouldn't be your "date" column, but if it is, put it second. > And to help the table scan of the ORDER table, should we also have "entit= y_id" > added to the index along with "due_date" i.e. a composite index on (entit= y_id,due_date)? I don't know; you'd have to test it on your test system. The current execution plan has no use for such an index, but adding additio= nal columns could 1. lead to an efficient index-only scan 2. make PostgreSQL pick an altogether different, better plan Yours, Laurenz Albe