0

I created table using exclude constraint.but i do not know the use of gist in exclude constraint?Why we specify the gist keyword in exclude constraint?.Any specify reason for this.

CREATE TABLE Employee_age_Details(
name varchar(50),
age integer,
EXCLUDE USING gist
(age WITH <>));
4
  • ok.but any specify reason for using gist in exclude constraint?.is it index? Commented Oct 25, 2019 at 9:15
  • thank you.so performances also improve for this column.am i correct? Commented Oct 25, 2019 at 9:18
  • @a_horse_with_no_name It actually does the opposite. The given EXCLUDE forces all employees to have the same age, not different. Commented Oct 25, 2019 at 15:22
  • @a_horse_with_no_name While GiST indexes offer the most flexibility, other ones do work with EXCLUDE. For example, you could do USING hash (age with =). Commented Oct 25, 2019 at 15:32

1 Answer 1

3

The default index type, Btree, does not offer support for the '<>' operator. The GiST index type (under btree_gist) does. You must use an index type which supports the operator.

If you changed the constraint operator to '=', then you could omit the "gist". But in that case you should just use a unique constraint, as it does the same thing better.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.