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 1pSVZY-0006AH-0U for pgsql-general@arkaria.postgresql.org; Thu, 16 Feb 2023 04:08:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pSVZW-0007Mj-KE for pgsql-general@arkaria.postgresql.org; Thu, 16 Feb 2023 04:08:38 +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 1pSVZW-0007MZ-7p for pgsql-general@lists.postgresql.org; Thu, 16 Feb 2023 04:08:38 +0000 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pSVZP-0001my-O9 for pgsql-general@lists.postgresql.org; Thu, 16 Feb 2023 04:08:37 +0000 Received: by mail-qt1-x835.google.com with SMTP id q13so998958qtx.2 for ; Wed, 15 Feb 2023 20:08:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=dGXAIJLz0Wr/2M5mNyPdXVdnnNwfULKygOYrgO3NZv4=; b=Zj9TFnSCP0pEPxwFf8SCSqcVDYtlG2V6Z8p7Ue6r06ayne6Tm2wZvpLLFeh81eCZTQ cGBfYdCO3OkPbWgYO0mquLkZ94/m/xZNRguscDC+2EXgV/0ERZmclYndO9U0gx0HVQKp UeFuaVEC3LYUY996wYNdI8mP9nrwD/+1APnJDAIDAbO/GUov91DHaijGrCnr5Felj3gD 80S81F/bLBrPBTvZ7WHuwy1Jd0iHkc5DZ1zwafL8wfsTyG7+un11tlh/86OF0P5rSW7g IPAN73gA0zS/dWEc9dOUNfLZE6pq5dpXaoqlRuxh0111fSep4fICVsZonB+Ryh0BddTr Zpxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dGXAIJLz0Wr/2M5mNyPdXVdnnNwfULKygOYrgO3NZv4=; b=rUQ2yarL4OhU50NZO1fcdOuTTJs6RrUtDBmeizN7GS13c6thZ2Dpd0kj+HNPh+F7eH xxjxw4yzrr22+i46FnXmBK7byOXaaY0kPeFJJkZPsGm3vj1/1s0Awh8VXwCQDWNmSVz4 NsplE2NwN+R94g3jfwX1QMI8ut9He7bFwdI5aTUZDpk96j3nGq0nDA9i9VdGeDhbdEeN FrdePY81EyqyBw22Sz3INqsquw0WhMrYc/DlOk+rIF5q43Yvo2Gkf2fzEMnrtpRPBopA 2vJOom9SyINX1aC7NkNTqB9d7toekfemT6L3jfFMPoYGxrj3cie+Ljph7wdmg2WaWi/J ITaQ== X-Gm-Message-State: AO0yUKX8JVADitRHA3jkhitQfpz9gO0G2sLfSTOfILpG1N0Km/M+kKni I0oKdpFOHqENW7CLbl0z7kHNvm7Q/SM= X-Google-Smtp-Source: AK7set9lCXZ+np1lMv9ByLUD2pJRy1N38t1hncl0pBeIxv44C4IUvcdxCs7A4NgYvuei2vMn9gPGXw== X-Received: by 2002:a05:622a:1985:b0:3b9:a42b:7099 with SMTP id u5-20020a05622a198500b003b9a42b7099mr8762716qtc.30.1676520510577; Wed, 15 Feb 2023 20:08:30 -0800 (PST) Received: from ?IPV6:2600:1700:bd2c:b810::43? ([2600:1700:bd2c:b810::43]) by smtp.googlemail.com with ESMTPSA id m123-20020a375881000000b0073b4cdb0745sm395285qkb.116.2023.02.15.20.08.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Feb 2023 20:08:30 -0800 (PST) Message-ID: Date: Wed, 15 Feb 2023 22:08:29 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Multi-column index: Which column order Content-Language: en-US To: pgsql-general@lists.postgresql.org References: <8780fa45a4041e4229f4a3fa88a61778d8534ab2.camel@cybertec.at> <3728c419-a158-4821-d736-dbd63a79c30d@gmail.com> <121cb8239ebfea29f059a263dc2a920f1f3f8604.camel@cybertec.at> From: Ron In-Reply-To: <121cb8239ebfea29f059a263dc2a920f1f3f8604.camel@cybertec.at> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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.