Hi,
We are facing problem with the recreation of existing indexes when hbm2ddl.auto is set to ‘update’.
We have tables with millions of data and it is dropping the existing indexes and creating again (which is taking too long to start the server).
Blockquote For example: I can see the following statements while server startup:
Hibernate: alter table order drop index UK_nv4v3d33juoq0x0iwtub87ftw
Hibernate: alter table order add constraint UK_nv4v3d33juoq0x0iwtub87ftw unique (order_id)
We are using Hibernate 5.3.7.Final. In hibernate config file ‘MySQL5Dialect’ dialect being used.
Of course using hibernate.hbm2ddl.auto=update is not a good idea in production, but I’m creating (flyway-) update-scripts with the help of org.hibernate.tool.hbm2ddl.SchemaUpdate and see the same drop-index-create-index-stuff, although apparently only for unique indexes.
@drahkrub Hi. I noticed the mention in your answer. I haven’t been working for Red Hat since March 2019, hence I don’t have the time to answer questions on this forum. You should ping one of the Hibernate ORM core developers. Cheers!
@vlad Many thanks for your message! And sorry to hear that - bad for Red Hat for sure and hopefully no problem for you. You’ve done a great work - keep it up!
Hi. We are having exact same issue with recreating only one (of many) unique index every time we run spring boot app with hibernate.hbm2ddl.auto=update property set.
We are using Hibernate 5.3.10.Final with PostgreSQLDialect.
Thanks for the reply @BeardOverflow. Shouldn’t its default option be RECREATE_QUIETLY? As it won’t modify the DB unnecessarily. Not sure why the default value is dropping the unique indexes first and then create. Anyway, Thanks it clarifies my question.