title: Indexing for key which belongs to Primary key of other table
body: <p>I have a two table as  table as</p>
  <pre><code>@Entity
   @Table(name = &quot;product&quot;, uniqueConstraints=@UniqueConstraint(columnNames={&quot;product_idn&quot;}))
  public class Product implements Serializable {
      private static final long serialVersionUID = 21409635044L;
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer id;
  
      private String product_idn;
  }
  </code></pre>
  <p>another table as</p>
  <pre><code>@Entity
  @Table(name = &quot;storage&quot;)
  public class Storage implements Serializable {
      private static final long serialVersionUID = -67165579239L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer id;
  
  @ManyToOne(fetch = FetchType.LAZY)
      @JoinColumn(name = &quot;product_id&quot;, nullable = false)
      @JsonBackReference
      private Product product;
  }
  </code></pre>
  <p>Now I am fetching record from <strong>storage</strong> table. Should create a index (Non-Unique)on <strong>product_id</strong> of storage table? I have to fetch storages count per on product/ featching storages based on product.</p>