Re: Query unable to utilize index without typecast to fixed length character - Mailing list pgsql-performance

From Tom Lane
Subject Re: Query unable to utilize index without typecast to fixed length character
Date
Msg-id 2307636.1680792630@sss.pgh.pa.us
Whole thread Raw
In response to Query unable to utilize index without typecast to fixed length character  (ahi <ahm3d.hisham@gmail.com>)
Responses Re: Query unable to utilize index without typecast to fixed length character
List pgsql-performance
ahi <ahm3d.hisham@gmail.com> 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



pgsql-performance by date:

Previous
From: ahi
Date:
Subject: Query unable to utilize index without typecast to fixed length character
Next
From: ahi
Date:
Subject: Re: Query unable to utilize index without typecast to fixed length character