Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add indexes for system file table #3

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

Kulbij
Copy link

@Kulbij Kulbij commented Apr 18, 2024

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
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
2 participants