Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/Helpers/LinkHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ static public function findSuitableEnding() {
*/
$base = env('POLR_BASE');

$link = Link::where('is_custom', 0)
/*$link = Link::where('is_custom', 0)
->orderBy('created_at', 'desc')
->first();
->first();*/

// This change works quite faster after an index creation on is_custom
$link = Link::whereRaw('id = (SELECT max(id) FROM links WHERE is_custom = 0)')->get()->first();

if ($link == null) {
$base10_val = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddLinkTableIndexOnIsCustom extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('links', function (Blueprint $table)
{
// This index helps to find quickly the last ending generated
$table->index('is_custom', 'links_is_custom_index');
});

}

public function down()
{
Schema::table('links', function (Blueprint $table)
{
$table->dropIndex('is_custom');
});
}
}