Skip to content

Commit

Permalink
[PERFORMANCE] Added index to the experius_page_not_found
Browse files Browse the repository at this point in the history
 This will reduce the load time of a 404 (in a case it was from 3.6s to 329ms)
  • Loading branch information
lewisvoncken committed Sep 14, 2020
1 parent f8bf918 commit b72738a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Experius\PageNotFound\Setup;

use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Setup\UpgradeSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;

class UpgradeSchema implements UpgradeSchemaInterface
{

/**
* {@inheritdoc}
*/
public function upgrade(
SchemaSetupInterface $setup,
ModuleContextInterface $context
) {
$setup->startSetup();
if (version_compare($context->getVersion(), "1.0.2", "<")) {
$this->addIndexesToTables($setup);
}
$setup->endSetup();
}

public function addIndexesToTables($setup)
{
$setup->getConnection()->query("ALTER TABLE `{$setup->getTable('experius_page_not_found')}` ADD INDEX `EXPERIUS_PAGE_NOT_FOUND_FROM_URL` (`from_url`(255));");
}
}
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Experius_PageNotFound" setup_version="1.0.1"/>
<module name="Experius_PageNotFound" setup_version="1.0.2"/>
</config>

0 comments on commit b72738a

Please sign in to comment.