Download the PHP package daniloromka/eav without Composer
On this page you can find all versions of the php package daniloromka/eav. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download daniloromka/eav
More information about daniloromka/eav
Files in daniloromka/eav
Informations about the package eav
EAV - jsonb
This is project is an implementation of the EAV (Entity-Attribute-Value) model based on PostgreSQL database using jsonb type.
This EAV-model combines the power of a relational database with the search speed of a non-relational database.
The idea was written here: https://coussej.github.io/2016/01/14/Replacing-EAV-with-JSONB-in-PostgreSQL/
Getting started
1. Basis
1.1. Creating the structure
Run this console command to create EAV model tables in the database (need use the correct DSN value to connect to the PostgreSQL database):
Will be output:
Successfully completed.
The result will be creating of 5 tables in your database with the prefix eavjsonb_
:
Note: You can add PDO_PGSQL_DSN setting to your .env file (see .env.example file)
1.2. Test data generation
Test data is needed here. Test data can be generated by the following console command:
Will be output:
Estimated execution time: 15 min
Successfully completed.
The result will be 10 million created entities with different attributes and values.
1.3. Data selecting test
You can test of data selecting from the EAV model by running the console command:
The test result can be as follows:
Total records count: 10000000
Filtered records count where {"1":"Value 1"}: 1
Execution time: 4728.9 ms
2. Adding indexing
2.1. Next, run this console command to adding indexing in the database:
The result of execution will be the creation index for jsonb field:
Estimated execution time: 18 min
Successfully completed.
2.2. Then it can be tested again by running the console command:
Now the test result will be as follows:
Total records count: 10000000
Filtered records count where {"1":"Value 1"}: 1
Execution time: 0.8 ms
This is a stunning result! This is less than 1 ms per 10 million records!
Implementation
You can use your migration mechanism to pull changes from the database after creating the EAV model tables.
Alternative implementation
Alternative is manual creating your migration with SQL-queries which is in the src/Migration/Setup*.php files.
All versions of eav with dependencies
ext-pdo Version *
ext-pdo_pgsql Version *
php Version ^5.0 || ^7.0 || ^8.0