pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Multi-column index: Which column order
Date: Wed, 15 Feb 2023 22:08:29 -0600
Message-ID: <cb3e7d0d-82f8-086d-0e42-759e8dca56da@gmail.com> (raw)
In-Reply-To: <121cb8239ebfea29f059a263dc2a920f1f3f8604.camel@cybertec.at>
References: <DBAP191MB12893BBE46573CA38E0FE921B0A29@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM>
	<8780fa45a4041e4229f4a3fa88a61778d8534ab2.camel@cybertec.at>
	<3728c419-a158-4821-d736-dbd63a79c30d@gmail.com>
	<121cb8239ebfea29f059a263dc2a920f1f3f8604.camel@cybertec.at>

On 2/15/23 21:45, Laurenz Albe wrote:
> On Wed, 2023-02-15 at 10:20 -0600, Ron wrote:
>> On 2/15/23 02:46, Laurenz Albe wrote:
[snip]
>>> Both are the same.
>>> There is an old myth that says that you should use the more selective column first
>>> (which would be "code"), but that is just a myth.
>> Only on Postgresql?
> No, on all relational databases that use B-tree indexes.

Not only is "all" is a very absolute word (I know of a counter-example), but 
querying on the second segment means that you have to scan the whole tree 
instead of isolating one sub-branch.

-- 
Born in Arizona, moved to Babylonia.





view thread (7+ messages)  latest in thread

Message-ID: <cb3e7d0d-82f8-086d-0e42-759e8dca56da@gmail.com>
Permalink:  ../cb3e7d0d-82f8-086d-0e42-759e8dca56da@gmail.com/
Also on:    postgresql.org/message-id/cb3e7d0d-82f8-086d-0e42-759e8dca56da@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: Multi-column index: Which column order
  In-Reply-To: <cb3e7d0d-82f8-086d-0e42-759e8dca56da@gmail.com>
  References: <DBAP191MB12893BBE46573CA38E0FE921B0A29@DBAP191MB1289.EURP191.PROD.OUTLOOK.COM> <8780fa45a4041e4229f4a3fa88a61778d8534ab2.camel@cybertec.at> <3728c419-a158-4821-d736-dbd63a79c30d@gmail.com> <121cb8239ebfea29f059a263dc2a920f1f3f8604.camel@cybertec.at> <cb3e7d0d-82f8-086d-0e42-759e8dca56da@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox