Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ktHqp-0007tK-Oc for pgsql-general@arkaria.postgresql.org; Sat, 26 Dec 2020 22:15:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ktHqo-0004I5-La for pgsql-general@arkaria.postgresql.org; Sat, 26 Dec 2020 22:15:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ktHqo-0004Hw-Br for pgsql-general@lists.postgresql.org; Sat, 26 Dec 2020 22:15:50 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ktHqj-0004Cf-D6 for pgsql-general@postgresql.org; Sat, 26 Dec 2020 22:15:49 +0000 Received: by mail-pj1-x102a.google.com with SMTP id lj6so4005083pjb.0 for ; Sat, 26 Dec 2020 14:15:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:message-id:in-reply-to:references:subject:mime-version; bh=zyReRFVt5Fd1f3bfKXqSpqvGsdB+TZGy3e09pPfyLEk=; b=YFJcJeZAj7p29YLc41DVpssddO3AoInPsToYhKWVODc1XM3yCNDSbSS9gsZ1vnppN3 /GS9Gv/AIpRRTTyANabJCoaz5phloSU7sbX7asHSEqlUrb92TAHgoaGDCzskTy4UIU6q EOq9t5XbwbyBXwkourjx1XE0C5VMova6Cs0hpXZzVmf6RnVrR/jbp+3NVwoSM/VEhp34 Ce2/bbSAI8DQzc86NlevmJxhuJ8XpEQ9EJd9nAACMEZFm7C+/OH7jq194wCS3g6csCdn O+2QNnRASTwhSwMO+DaY+meDGy/VcoRbvjjHohVN6zMitEYSXcs1QSrJElUHqolinosK IVrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:message-id:in-reply-to:references :subject:mime-version; bh=zyReRFVt5Fd1f3bfKXqSpqvGsdB+TZGy3e09pPfyLEk=; b=jQ2Biw6Alm0vgcFRAPB+bKNi51rqMtP5JB8ildUDRuUJoa5CIUXz3ElIBF1N7BMarO WcXBMcZVH/TeMSbCo95q9eVs6gEVC1nmCOJ2FivwHdRa9ESmO/KMiC4FxQIM7+m7p92y z/gC+B5tCFqeizIrZHKiW/mrsooS/olbzun/07YoWxjvOST5ygSmhkDGU9//f07i2/4F MsRpQGP0gUvURi0hQqp/d7tiG5E3BtKW0WuCFMHHLTm4ceiH5ye2AyDg37Jlt+iC1iFQ XX8sUe2ECN8Do9uLQVb9apcCNuJQJibE9MSF51/0m1W6U/dz1vjZxArNicWHWhKUttbI MP9w== X-Gm-Message-State: AOAM531tre9CLZjy+wfaZwM/BRnbm/Kn9sMkHGeJCNw7hUVGMkHAXGeX RqyVcc8yqlfrL9P9D1+PHg6Vqv4Z7KEIyA== X-Google-Smtp-Source: ABdhPJwNWj7/GJai27DDsMeCp1wHUGVYsQLGxzbNCpMHuUZ/ilamde4RlDYqrV08rADv1EXm36rZ0w== X-Received: by 2002:a17:90a:7844:: with SMTP id y4mr14425776pjl.68.1609020943969; Sat, 26 Dec 2020 14:15:43 -0800 (PST) Received: from [2600:8801:8800:11:e0f2:5687:200:0] ([2600:8801:8800:11::f]) by smtp.gmail.com with ESMTPSA id f9sm31843859pfa.41.2020.12.26.14.15.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Dec 2020 14:15:43 -0800 (PST) Date: Sat, 26 Dec 2020 14:15:36 -0800 From: Guyren Howe To: Pgsql-general General , Shantanu Shekhar Message-ID: <36104373-38ae-44da-bd2a-680922429632@Spark> In-Reply-To: <1135969024.2853124.1609013901725@mail.yahoo.com> References: <1135969024.2853124.1609013901725.ref@mail.yahoo.com> <1135969024.2853124.1609013901725@mail.yahoo.com> Subject: Re: Multi-column index vs index on individual columns X-Readdle-Message-ID: 36104373-38ae-44da-bd2a-680922429632@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="5fe7b60d_79e2a9e3_d21" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --5fe7b60d_79e2a9e3_d21 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline In a typical web storefront or catalog app, there are a fairly small number of queries that are run often that are more complex and slower. It is perfectly appropriate to consider creating compound/partial indexes to speed up those queries. Just be aware that indexes trade off slower insert/update time against faster search time. I would read use-the-index-luke.com for detailed advice about using compound and partial indexes effectively. On Dec 26, 2020, 12:18 -0800, Shantanu Shekhar , wrote: > Hi, > > I was going through Postgres documentation on multi-column indexes and came across the recommendation at the bottom states: "Multicolumn indexes should be used sparingly. In most situations, an index on a single column is sufficient and saves space and time". > > In my experience typical webapps the queries are known ahead of time and lot of the times the queries are restricted to a single table (no joins). Does this recommendation that still apply in this use-case? I was under the impression that instead of scanning multiple indexes and then combining the results, it may be more performant to simply use a single multi-index column. > > Thanks, > > Shantanu --5fe7b60d_79e2a9e3_d21 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
In a typical web storefront or catalog app, there a= re a fairly small number of queries that are run often that are more comp= lex and slower. It is perfectly appropriate to consider creating compound= /partial indexes to speed up those queries. Just be aware that indexes tr= ade off slower insert/update time against faster search time. I would rea= d use-the-index-luke.com for detailed advice about using compound and par= tial indexes effectively.
On Dec 26, 2020, 12:18 -0800, Shant= anu Shekhar <shekharshan=40yahoo.com>, wrote:
Hi,

I was going through Postgr= es documentation on multi-column indexes and came across the recommendati= on at the bottom states: =22Multico= lumn indexes should be used sparingly. In most situations, an index on a = single column is sufficient and saves space and time=22.&=23160;

In my experience typical webapps the queries are known ahead = of time and lot of the times the queries are restricted to a single table= (no joins). Does this recommendation that still apply in this use-case=3F= I was under the impression that instead of scanning multiple indexes and= then combining the results, it may be more performant to simply use a si= ngle multi-index column.&=23160;

Thanks,

Shantanu
--5fe7b60d_79e2a9e3_d21--