Real use of React Native op-sqlite with TypeORM and performance questions

Lukasz Kurant
3 min readApr 28, 2024

--

Measuring the performance of the library.

Photo by Kolleen Gladden on Unsplash

Last year I prepared an article examining the performance of the React Native Quick SQL library running with JSI:

However, due to the closure of the project, my attention turned to the op-sqlite library. The author presents in the documentation a significant performance increase over RN Quick SQL. However, due to the use of a real-world example, I would like to test this library in a real-world application, such as with integration with an ORM library such as TypeORM.

In my example, I applied exactly the same test using a Person object having the following fields:

import {Entity, Column, BaseEntity, PrimaryGeneratedColumn} from 'typeorm';

@Entity('people')
export class Person extends BaseEntity {
@PrimaryGeneratedColumn() id: number;
@Column('datetime') createdAt: Date;
@Column('text') firstName: string;
@Column('text') lastName: string;
@Column('text') age: number;
}

Objects of this type are written, read, modified and deleted in appropriate groups. The details of the experiment are described in the acrylic mentioned above. In summary performance was measured for the following tests:

  • Creation of 10000 records,
  • Creation of 100000 records,
  • Query 10000 records,
  • Query 100000 records.

In addition, update and deletion tests have been carried out, but the results in all libraries are quite similar, and thus less interesting.

Tests

The tests were conducted in Release mode, on real devices. The version of React Native is 0.73.7, TypeORM 0.3.20, for the following database libraries:

The tests were run 5 times, and an average was drawn from the results. The devices tested were iPhone 11 and Pixel 4.

Since the library TypeORM. needs a driver to work properly, and the op-sqlite library does not have one built into the library, I prepared the module myself. The code looks as follows here.

Results

Detailed values are available here.

As you can see from the graphs, I can’t see any real performance increase between Quick SQLite and op-sqlite libraries. Similar doubts are raised in one of the threads in Issues in the library. It is possible that in the case of the more top-end smartphones of today, the results have a greater more significant difference, but I have serious doubts about the real scale of the performance improvement especially the one presented by the author at the beginning of the documentation.

This does not change the fact that the op-sqlite library is still the best possible choice for handling sqlite in React Native.

You can find the projects being tested here: https://github.com/lukaszkurantdev/blog-sqlite-comparison

--

--

Lukasz Kurant

Fullstack Developer interested in solving difficult problems.