Skip to content

Add indexes for system file table#3

Open
Kulbij wants to merge 1 commit into
octoberrain:developfrom
Kulbij:add-indexes-system-file-table
Open

Add indexes for system file table#3
Kulbij wants to merge 1 commit into
octoberrain:developfrom
Kulbij:add-indexes-system-file-table

Conversation

@Kulbij

@Kulbij Kulbij commented Apr 18, 2024

Copy link
Copy Markdown

Work has been done to add indexes for the system_files table.
As a result, we get an increase in the speed of queries to the system_fiels table.
Testing was carried out on high-load projects with a large number of images > 1 million for different models (for example: Products, Articles, etc.).

After adding indexes for the system_files table, the speed of the project (queries to the database) increased several times.

@Kulbij Kulbij marked this pull request as ready for review April 18, 2024 12:45
@daftspunk

Copy link
Copy Markdown
Contributor

Hi @Kulbij

Thanks for this. Can you confirm that the following schema has the necessary indexes for performance? If not, could you please modify it based on your findings?

Schema::create('system_files', function (Blueprint $table) {
    $table->increments('id');
    $table->string('disk_name');
    $table->string('file_name');
    $table->integer('file_size');
    $table->string('content_type');
    $table->string('title')->nullable();
    $table->text('description')->nullable();
    $table->string('field')->nullable();
    $table->integer('attachment_id')->nullable();
    $table->string('attachment_type')->nullable();
    $table->boolean('is_public')->default(true);
    $table->integer('sort_order')->nullable();
    $table->timestamps();

    $table->index(['attachment_type', 'attachment_id', 'field'], 'system_files_master_index');
});

You can paste it as a comment here, if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants