문제

Do I need to add an index anoatation for the primary key of a hibernate table for decent performance, I assumed that marking a field with @id would mean an index was created

@Id
private String guid;

but I didnt notice anything being created in the ddl that was generated

But if I added an @index annotation

@Id
@org.hibernate.annotations.Index(name = "IDX_GUID")
private String guid;

then I do notice an index being created in the DDL.

So I'm thinking I need to do this for every table, but part of me is thinking is this really neccessary as surely hibernate would want indexes created for the primary key as a starting point ?

도움이 되었습니까?

해결책

You do NOT have to create index explicitly. Instead of seeing DDL statements; I will recommend you to check the final schema created by hibernate. The index is created as part of create table statement.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top