I have a Term table with just over 5 million rows. Each line consists of an identifier and a name. A search with the name field takes almost 35 seconds.
MariaDB [WordDS]> select * from Term where name="Google";
+---------+--------+
| id | name |
+---------+--------+
| 1092923 | Google |
+---------+--------+
1 row in set (35.35 sec)
script from the table generated by Hibernate:
DROP TABLE IF EXISTS `Term`;
;
;
CREATE TABLE `Term` (
`id` bigint(20) NOT NULL,
`name` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
;
Java Annotations:
@Id
@Column(unique=true)
private long id;
@NotNull
@Size(min = 1, max = 100)
private String name;
So slowly search in the "name" field, so I think there is no index. Does Hibernate automatically create an index for the id and name in this table? If not, how to allow creating an index for both?
source
share