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 1tt5b8-008UBw-Ge for pgsql-general@arkaria.postgresql.org; Fri, 14 Mar 2025 14:01:14 +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 1tt5b6-008A3e-2W for pgsql-general@arkaria.postgresql.org; Fri, 14 Mar 2025 14:01:12 +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 1tt5b5-008A3W-Ng for pgsql-general@lists.postgresql.org; Fri, 14 Mar 2025 14:01:11 +0000 Received: from mail-il1-x135.google.com ([2607:f8b0:4864:20::135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tt5b2-002qU9-0N for pgsql-general@postgresql.org; Fri, 14 Mar 2025 14:01:11 +0000 Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-3d450154245so17196065ab.2 for ; Fri, 14 Mar 2025 07:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741960868; x=1742565668; 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=eGGwaclRQv25BW3t1Bt/I8vVK1wFO1EjhTrhhQzO2Pc=; b=XO5NrPcvzGswrVCkNDNvSVjyoAcwDZvrTwk3bxaIJ6/J7ZYNcMjuHj6yihtYw4oP0Z 40UQNgXA8u4jLdVSY6J+V0hC3Nh4SoS+biFYVOMvFy5S2U9EeM6u0n/b7orYMQ8cFHgD 2o0dWBZdzDUGZuy4ZR8hBupnLZWwXZK3xMjRcGPyd6+aUbihSpxPGa04D0eNJtx7kIgQ iNzJBdZu4COMOHZSSWbdrVs+opQESRtPjchC3R5xTAHMjAkCLAuLuhUF1O23QX5zc3xc KyY0xDy/q9U4EDMAtlDLusO5Ypch/h0euF2t6Hko3rFWjsbzZL07QAccQanDu4Xq2Xua bSrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741960868; x=1742565668; 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=eGGwaclRQv25BW3t1Bt/I8vVK1wFO1EjhTrhhQzO2Pc=; b=kmVoZNS4aQipK8fM5RuXNDtEd/AMDA5pv0UUzna6IvJe8v6TcrBKXkPD5DQ5Faca2g 1QYiz7Qjo7Rz+RkO7b7fCkf7l9Zw42tVz1hxv2onFi3p0Xw0Wry3geebM3yjZl+0OrGU vf9SWUpj6mL4AFYUEMoFZLtfeppJoLJ44jiO2aLU0r+k8P9Kb54j8ZorgjyCjS3xJiFG WF9kTfGhK72QLk+OO7vAHj+OsFb7Y+dkj90/ZpC8b3hzHyg9ldvgJfcIYp2Z/R0g577d jptcW21mweUfLk3L24v01yightZ96YYD273XmKx3RjkWjY1P7BgGiNze/MSNnY63dJvM gV6A== X-Forwarded-Encrypted: i=1; AJvYcCXdSe+40wId3NXgAMRqAanPMABwF2HeYOiWjC0RriQAF5O0yptFKDbpydL5zyJ7o6khWGWHE46j4xX5YPuJ@postgresql.org X-Gm-Message-State: AOJu0Yz7JHFCv9S5JB5ig3Keozoimwuk0MPFCjlMxSZigKFMV18YNGUj vaXXM5pAqun0Dc8UyadfqL2li/iJgoKLfJfx0xvpzXhuapF5z5VvZL8OwJKVh/cPaYg+oNhyeVX iHKCvNoPzDu4SUPr5/IQLkSqLRYQ= X-Gm-Gg: ASbGnctFgG6fyNInkZ/vEQP7oLZoPG4yS87Nps0Exc80xsmDMQaNhqEpyK4nuV8xXQt eR84Nv/P4acgb5X0hsfY0bzWQWdBwllfvAZpI46r8JaTfU4B519NP/XHvfikJy2UwnlBhNmhrYg 0jlS6G6bfrfeV3sz54KuNHpk+JkWj4850wudM/iACvVz8RrctOvkuWScOxUkBqCBoGu7bphsk= X-Google-Smtp-Source: AGHT+IEQMjzriDEDD0EVvFIKqeAU22a0HQanhj+af/g+p34REnO8OkxeynuS3XQh54ybQ8oGtlYrUh0PyE0QCaorQAU= X-Received: by 2002:a05:6e02:220b:b0:3d4:38a4:388e with SMTP id e9e14a558f8ab-3d483a004edmr24241525ab.1.1741960867504; Fri, 14 Mar 2025 07:01:07 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Fri, 14 Mar 2025 10:00:31 -0400 X-Gm-Features: AQ5f1JoxEdixqyBdTE7bmQHrq4eyCTTB-_QLMODG-NMAJ-77zR3ax-MjTec-OwY Message-ID: Subject: Re: Query optimization To: Durgamahesh Manne Cc: Ron Johnson , pgsql-general Content-Type: multipart/alternative; boundary="000000000000b86e9106304ddead" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000b86e9106304ddead Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 13, 2025 at 11:49=E2=80=AFPM Durgamahesh Manne < maheshpostgres9@gmail.com> wrote: > To return one row takes 43ms is not optimal > It's actually much faster than that, but even 43ms is overall good. The query is already pretty optimal, as it uses a single index only scan. There are a few tricks left to make this potentially faster, but you may want to look into using some sort of in-memory caching system if your application is that sensitive to timings. Or find us a version in which the execution time is not 1/20th of a millisecond and we can work on that one. Also take a look at pg_stat_statements so you can see how fast the query is on average. Cheers, Greg -- Crunchy Data - https://www.crunchydata.com Enterprise Postgres Software Products & Tech Support --000000000000b86e9106304ddead Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Mar 13, 2025 at 11:49=E2=80=AFPM = Durgamahesh Manne <maheshpo= stgres9@gmail.com> wrote:
To return one row takes 43ms is not optimal=C2=A0

It's actually much faster tha= n that, but even 43ms is overall good. The query is already pretty optimal,= as it uses a single index only scan. There are a few tricks left to make t= his potentially faster, but you may want to look into using some sort of in= -memory caching system if your application is that sensitive to timings. Or= find us a version in which the execution time is not 1/20th of a milliseco= nd and we can work on that one.

Also take a look a= t pg_stat_statements so you can see how fast the query is on average.
=

Cheers,
Greg

--
Enterprise Postgres Software Products = & Tech Support

--000000000000b86e9106304ddead--