Re: Multi-column index: Which column order

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Multi-column index: Which column order
Date: 2023-02-16 04:08:29
Message-ID: cb3e7d0d-82f8-086d-0e42-759e8dca56da@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mikhail Balayan 2023-02-16 06:57:37 Automatic aggressive vacuum on almost frozen table takes too long
Previous Message Amit Kapila 2023-02-16 04:00:52 Re: Support logical replication of DDLs