I know (contract) we need to override hashcode when equals is overridden.
Why should I consider same fields used for equals comparison to compute hashcode?
Is it to improve performance, by avoiding too many objects mapping to same bucket, as in below case?
i.e. all objects created on same "date" would map to same bucket and linear comparison will take time in checking object exists using equals() method?

If my above statement is true, what other potential issues will come with below code other than performance issue. Is that the only reason we should use same fields / members used in equals to compute hashcode? Please share. Thanks. 

```
class MyClass {
  int date;
  int pay;
  int id;

  public boolean equals(Object o) {
    //null and same class instance check
    MyClass obj = (MyClass) o;
    return (date == obj.date && pay == obj.pay && id == obj.id);
  }

  public int hashCode() {
    int hash = 7;
    return (31 * hash + date);
  }
}

```

//please pardon syntax errors, I typed without using ide.

\*\*\*my intention is to use all fields in equals, and know why same number of elements should be used in hashcode, and what happens if only few elements are used

**Clarification:** 
With only using "date" to compute hashcode,pointer checks right bucket address (do you agree?) furthermore, I get list of items in that bucket, collection will iterate over to check if particular obj exists using equals. And my definition of equals is "all fields must be same". With this, I believe my code works fine, and I only find performance issue. Please point out where I am wrong. Thank you