Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TYPE CUSTOMER_TYPE AS ENUM
- ('enum1', 'enum2', 'enum3', '...', 'enum15'); ## max lenght of enum names ~15
- CREATE TABLE CUSTOMER(
- CUSTOMER_ONE TEXT PRIMARY KEY NOT NULL, ## max 35 char String
- ATTRIBUTE_ONE TEXT UNIQUE, ## max 35 char String
- ATTRIBUTE_TWO TEXT, ## 1-80 char String
- PRIVATEKEYTYPE CUSTOMER_TYPE ## see enum
- );
- select * from customer
- where Customer_One='XXX' OR Attribute_One='XXX';
- CREATE TABLE customer (
- privatekeytype customer_type -- move the enum to 1st pos to save some more
- , customer_one text PRIMARY KEY
- , attribute_two text
- );
- CREATE INDEX customer_attribute_one_idx ON customer (hash(customer_one));
- SELECT *
- FROM customer
- WHERE 'XXX' IN (customer_one, hash(customer_one));
- -> BitmapOr (cost=5.34..5.34 rows=5 width=0)
- -> Bitmap Index Scan on customer_pkey (cost=0.00..2.66 rows=1 width=0)
- Index Cond: ('XXX'::text = customer.customer_one)
- -> Bitmap Index Scan on customer_attribute_one_idx (cost=0.00..2.68 rows=4 width=0)
- Index Cond: ('XXX'::text = hash(customer.customer_one))
Add Comment
Please, Sign In to add comment