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 1ngqke-0008UJ-5g for pgsql-sql@arkaria.postgresql.org; Tue, 19 Apr 2022 16:30:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ngqkc-0004X5-P3 for pgsql-sql@arkaria.postgresql.org; Tue, 19 Apr 2022 16:30:50 +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 1ngqkc-0004Ww-GK for pgsql-sql@lists.postgresql.org; Tue, 19 Apr 2022 16:30:50 +0000 Received: from smtp99.ord1d.emailsrvr.com ([184.106.54.99]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ngqka-00075B-74 for pgsql-sql@lists.postgresql.org; Tue, 19 Apr 2022 16:30:49 +0000 X-Auth-ID: xof@thebuild.com Received: by smtp5.relay.ord1d.emailsrvr.com (Authenticated sender: xof-AT-thebuild.com) with ESMTPSA id E3667A00F3; Tue, 19 Apr 2022 12:30:45 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: Create index on user defined type From: Christophe Pettus In-Reply-To: Date: Tue, 19 Apr 2022 09:29:37 -0700 Cc: pgsql-sql X-Mailbutler-Message-Id: D51A0043-AD10-47E0-A2E8-C5375E877510 Content-Transfer-Encoding: quoted-printable Message-Id: <4D6ADD6D-0E11-4E6C-BF6D-AFB57FFF1B67@thebuild.com> References: To: aditya desai X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Classification-ID: ed22ebcf-ac49-4837-ba6d-542052eed96d-1-1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Apr 19, 2022, at 09:27, aditya desai wrote: >=20 > Hi, > Is there any way to create index on user defined type in Postgresql? = Need to create index on bug_status in bug table. >=20 > CREATE TYPE bug_status AS ENUM ('new', 'open', 'closed'); >=20 > CREATE TABLE bug ( > id serial, > description text, > status bug_status > ); It works right out of the box: xof=3D# CREATE TYPE bug_status AS ENUM ('new', 'open', 'closed'); CREATE TYPE xof=3D# CREATE TABLE bug ( id serial, description text, status bug_status ); CREATE TABLE xof=3D# create index on bug(status); CREATE INDEX xof=3D#=20