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 1pkQwk-0001t1-Ez for pgsql-performance@arkaria.postgresql.org; Thu, 06 Apr 2023 14:50:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pkQwi-0008Pg-3Z for pgsql-performance@arkaria.postgresql.org; Thu, 06 Apr 2023 14:50:40 +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 1pkQwh-0008PX-Ov for pgsql-performance@lists.postgresql.org; Thu, 06 Apr 2023 14:50:39 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pkQwb-0001aT-1K for pgsql-performance@lists.postgresql.org; Thu, 06 Apr 2023 14:50:38 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 336EoUhm2307637; Thu, 6 Apr 2023 10:50:31 -0400 From: Tom Lane To: ahi cc: pgsql-performance@lists.postgresql.org Subject: Re: Query unable to utilize index without typecast to fixed length character In-reply-to: References: Comments: In-reply-to ahi message dated "Thu, 06 Apr 2023 12:23:41 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2307635.1680792630.1@sss.pgh.pa.us> Date: Thu, 06 Apr 2023 10:50:30 -0400 Message-ID: <2307636.1680792630@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ahi writes: > CREATE TABLE public.marketplace_sale ( > log_index integer NOT NULL, > created_at timestamp with time zone DEFAULT now() NOT NULL, > updated_at timestamp with time zone DEFAULT now() NOT NULL, > block_timestamp timestamp with time zone NOT NULL, > block bigint NOT NULL, > contract_address character(42) NOT NULL, > buyer_address character(42) NOT NULL, > seller_address character(42) NOT NULL, > transaction_hash character(66) NOT NULL, > quantity numeric NOT NULL, > token_id numeric NOT NULL, ... Type character(N) is a hangover from the days of punched cards. Don't use it. It has weird semantics concerning trailing spaces, which are almost never the behavior you actually want, and cause interoperability issues with type text. (Text is Postgres' native string type, meaning that unlabeled string constants will tend to get resolved to that.) regards, tom lane