Lealone is an OLTP database that claims to be 10 times faster than MySQL

picture

1. Introduction

Lealone is a high-performance relational database for OLTP scenarios. Lealone is an asynchronous NewSQL stand-alone and distributed relational database product for OLTP/OLAP scenarios that combines the advantages of RDBMS and NoSQL. It can be used as an independent database, a microservice framework, or both at the same time. It supports high-performance distributed transactions, strong consistency replication, global snapshot isolation, and extremely explosive concurrent write performance. It is said to be an OLTP database that is 10 times faster than MySQL. Currently Lealone 5.2 has been released, a long-term support (LTS) and milestone version.

2. Lealone characteristics

Highlight properties

  • Concurrent write performance is extremely explosive

  • Full-link asynchronous, using a small number of threads to handle a large amount of concurrency

  • Pausable, progressive SQL engine

  • Preemptive scheduling based on SQL priority, slow queries will not occupy the CPU for a long time

  • Creating a JDBC connection is very fast, takes up few resources, and no longer requires a JDBC connection pool.

  • Plug-in storage engine architecture, built-in AOSE engine, and novel asynchronous B-Tree

  • Plug-in transaction engine architecture, separation of transaction processing logic and storage, built-in AOTE engine

  • Supports Page-level mixed row and column storage. For tables with many fields, reading only a few fields can save a lot of memory.

  • Supports creating hostable backend services via the CREATE SERVICE statement

  • It only requires a jar package of less than 2M to run, and no installation is required.

Common characteristics

  • Supports indexes, views, Join, subqueries, triggers, custom functions, Order By, Group By, and aggregation

Enterprise Edition

  • Supports high-performance distributed transactions, strong consistency replication, and global snapshot isolation

  • Supports automated sharding (Sharding), users do not need to care about any sharding rules, there are no hot spots, and range queries can be performed

  • Supports mixed operating modes, including 4 modes: embedded, Client/Server mode, replication mode, Sharding mode

  • Supports quick manual or automatic switching of operating modes without downtime: Client/Server mode -> Copy mode -> Sharding mode

3. Application scenarios

  • Using Lealone's distributed SQL engine, you can use MySQL-like SQL syntax and standard JDBC API to read and write data in HBase. It supports various DDL, triggers, custom functions, views, Join, subqueries, Order By, and Group. By, aggregation.

  • For traditional stand-alone RDBMS scenarios with Client/Server architecture, Lealone can also be used.

  • If the application wants to read and write the database directly without going through the network, embedded Lealone can be used.

4. Lealone architecture

picture

5. Relevant addresses

github

https://github.com/lealone

Document address

https://github.com/lealone/Lealone-Docs

6. Integrated use

1. Add Lealone dependency

Add Lealone driver dependencies in the pom.xml file

<dependencies>
    <dependency>
        <groupId>org.lealone</groupId>
        <artifactId>lealone-client</artifactId>
        <version>5.2.0</version>
    </dependency>
</dependencies>

2. Configure data source

Configure the data source in the application.yml or application.properties file

spring:
  datasource:
    driver-class-name: com.lealone.jdbc.Driver
    url: jdbc:lealone://localhost:3306/test
    username: root
    password: 123456

3. Create entity class

Create an entity class for mapping database tables

@Data
public class SysUser {
    private Integer id;
    private String name;
    private Integer age;
}

4. Create Mapper interface

Create an interface inherited from BaseMapper for operating the database

@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

}

5. Using Mapper in ServiceImpl

Use @Resource annotation in ServiceImpl to inject Mapper, and then you can call its methods to operate the database

@Slf4j
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {

  @Resource
  private SysUserMapper sysUserMapper;
  
  @Override
  public List<SysUser> findAll() {
        return sysUserMapper.findAll();
    }

}

6. JDBC CRUD example


public class CRUDLealone {
    public static void main(String[] args) throws Exception {
        String url = "jdbc:lealone:tcp://localhost:3306/lealone";
        Connection conn = DriverManager.getConnection(url, "root", "123456");
        Statement stmt = conn.createStatement();

        stmt.executeUpdate("CREATE TABLE IF NOT EXISTS sys_user (id int primary key,name varchar, age int)");
        stmt.executeUpdate("INSERT INTO sys_user(id, name, age) VALUES(1, 'ahope', 30)");
        stmt.executeUpdate("UPDATE sys_user SET age = 31 WHERE id = 1");
        ResultSet rs = stmt.executeQuery("SELECT * FROM sys_user");
        while (rs.next()) {
            System.out.println("id=" + rs.getInt(1) + "name=" + rs.getString(2) + " age=" + rs.getInt(3));
        }
        rs.close();
        stmt.executeUpdate("DELETE FROM sys_user WHERE id = 1");
        stmt.executeUpdate("DROP TABLE IF EXISTS sys_user");
        stmt.close();
        conn.close();
    }
}

picture

Guess you like

Origin blog.csdn.net/weixin_40381772/article/details/133122142