【问题标题】:Use XtraDB as a storage engine in a Spring Boot & Hibernate application在 Spring Boot & Hibernate 应用程序中使用 XtraDB 作为存储引擎
【发布时间】:2019-01-02 15:35:10
【问题描述】:

我正在开发一个使用 Spring Boot 2.0.3、Hibernate 5.2.17 和 MariaDB 10.1.29 的项目。当hibernate生成表时,我试图将存储引擎设置为XtraDB,但没有成功。

这是我的 application.properties 文件:

spring.thymeleaf.cache=false

spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.url=jdbc:mariadb://localhost:3306/bookstore-db
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=****
spring.datasource.hikari.connection-timeout=20000
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=12
spring.datasource.hikari.idle-timeout=300000
spring.datasource.hikari.max-lifetime=1200000
spring.datasource.hikari.auto-commit=true

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB53Dialect
spring.jpa.properties.hibernate.dialect.storage_engine=xtradb

spring.jpa.hibernate.ddl-auto=update

即使指定 spring.jpa.properties.hibernate.dialect.storage_engine=xtradb,它仍然使用 InnoDB,如控制台所示:

create table hibernate_sequence (
   next_val bigint
) engine=InnoDB
Hibernate: 

insert into hibernate_sequence values ( 1 )
Hibernate: 

create table user (
   id_user bigint not null,
    email varchar(255) not null,
    enabled bit not null,
    first_name varchar(255),
    last_name varchar(255),
    password varchar(255),
    phone varchar(255),
    username varchar(255),
    primary key (id_user)
) engine=InnoDB

感谢您的帮助。

【问题讨论】:

  • 只使用 InnoDB。
  • 问题是对于低于 10.2 的 MariaDB 版本,出于性能原因建议使用 XtraDB link
  • 是的,XtraDB 更好。适用于 1% 的应用程序。其他 99% 的人不会注意到显着差异。
  • 好吧,我看了你的个人资料,我认为你很有经验,所以我会听取你的建议。

标签: mysql spring hibernate spring-boot mariadb


【解决方案1】:

嗯,自 MariaDB 10.2 以来,InnoDB 被用作默认和最佳选择。这些是他们site上提到的原因

XtraDB 在 5.1 和 5.5 中比 InnoDB 有许多很大的改进。但随着时间的推移,MySQL 已经实现了几乎所有这些。 InnoDB 已经迎头赶上,而 XtraDB 只是稍微好一点......

特别是,XtraDB 5.7 似乎唯一真正的改进是针对写入密集型 I/O 绑定的工作负载,其中禁用了 innodb_thread_concurrency 控制。

因此,对于那些使用最新版本 MariaDB 的人来说,没有更多理由切换到 XtraDB。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多