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 1t41it-00G0Z4-Mo for pgsql-admin@arkaria.postgresql.org; Thu, 24 Oct 2024 17:34:12 +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 1t41ir-0067yo-7r for pgsql-admin@arkaria.postgresql.org; Thu, 24 Oct 2024 17:34:09 +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 1t41iq-0067yL-Km for pgsql-admin@lists.postgresql.org; Thu, 24 Oct 2024 17:34:09 +0000 Received: from mail2.pscs.co.uk ([178.159.10.131] helo=mail.pscs.co.uk) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t41im-002lwg-QN for pgsql-admin@lists.postgresql.org; Thu, 24 Oct 2024 17:34:06 +0000 Authentication-Results: mail.pscs.co.uk; spf=none; auth=pass (cram-md5) smtp.auth=pscs Received: from lmail.pscs.co.uk ([192.168.120.1]) by mail.pscs.co.uk ([192.168.120.185] running VPOP3) with ESMTPSA (TLSv1.3 TLS_AES_256_GCM_SHA384) for ; Thu, 24 Oct 2024 18:34:02 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pscs.co.uk; q=dns/txt; s=lmail; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To :Content-Type:Content-Transfer-Encoding:Cc:Reply-to:Sender; t=1729790936; x=1730395736; bh=pBIJYLlYAywzAomXQvxpKeswfnGStlUF4Ggi1bhosDc=; b=UVLCra0hjrGfCXz4+4EDO8NH3uxF4ty1nqS8eC++/IicEQ7j0rMXwVCFWD0rTItQSQJat2lJ 8Qx+0LIPIyNIkAZObv+hTi3mEbOXqS8MsB8lexALWhrZx2jn0RR6O9yZxbT7QMlJzK3Ig4lGDo CbOoF0moN8kZrrFLRaON0+898= Authentication-Results: lmail.pscs.co.uk; spf=none; auth=pass (cram-md5) smtp.auth=paul Received: from [192.168.57.71] ([217.155.111.120] (217-155-111-120.dsl.in-addr.zen.co.uk)) by lmail.pscs.co.uk ([192.168.120.70] running VPOP3) with ESMTPSA (TLSv1.3 TLS_AES_256_GCM_SHA384) for ; Thu, 24 Oct 2024 18:28:56 +0100 Message-ID: <09715bfd-53aa-4504-8400-355d3682158a@pscs.co.uk> Date: Thu, 24 Oct 2024 18:28:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Partitioned table scanning all pertitions when the where clause specifies the partition key Content-Language: en-GB To: pgsql-admin@lists.postgresql.org References: <31a09bff-78df-468b-8783-4bb5ebc8c0c9@quadratum-braccas.com> From: Paul Smith* In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Sender: paul X-Server: VPOP3 Enterprise V8.7 - Registered X-Organisation: Paul Smith Computer Services X-VPOP3Tester: 12 345 X-Authenticated-Sender: pscs List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 24/10/2024 18:16, Keith Fiske wrote: > > Since your index is functional, in order to use the index, the queries > must use that same function in the condition. Try doing > > EXPLAIN SELECT * FROM customers where lastname = upper('BORRIS'); I thought you'd need to use the same function exactly. EXPLAIN SELECT * FROM customers where upper(lastname) = upper('BORRIS'); As the index is on 'upper(lastname)', 'upper(lastname)' has to be in the query Paul