Guest User

Untitled

a guest
Dec 15th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. CREATE TYPE CUSTOMER_TYPE AS ENUM
  2. ('enum1', 'enum2', 'enum3', '...', 'enum15'); ## max lenght of enum names ~15
  3.  
  4. CREATE TABLE CUSTOMER(
  5. CUSTOMER_ONE TEXT PRIMARY KEY NOT NULL, ## max 35 char String
  6. ATTRIBUTE_ONE TEXT UNIQUE, ## max 35 char String
  7. ATTRIBUTE_TWO TEXT, ## 1-80 char String
  8. PRIVATEKEYTYPE CUSTOMER_TYPE ## see enum
  9. );
  10.  
  11. select * from customer
  12. where Customer_One='XXX' OR Attribute_One='XXX';
  13.  
  14. CREATE TABLE customer (
  15. privatekeytype customer_type -- move the enum to 1st pos to save some more
  16. , customer_one text PRIMARY KEY
  17. , attribute_two text
  18. );
  19.  
  20. CREATE INDEX customer_attribute_one_idx ON customer (hash(customer_one));
  21.  
  22. SELECT *
  23. FROM customer
  24. WHERE 'XXX' IN (customer_one, hash(customer_one));
  25.  
  26. -> BitmapOr (cost=5.34..5.34 rows=5 width=0)
  27. -> Bitmap Index Scan on customer_pkey (cost=0.00..2.66 rows=1 width=0)
  28. Index Cond: ('XXX'::text = customer.customer_one)
  29. -> Bitmap Index Scan on customer_attribute_one_idx (cost=0.00..2.68 rows=4 width=0)
  30. Index Cond: ('XXX'::text = hash(customer.customer_one))
Add Comment
Please, Sign In to add comment