Skip to main content
50 votes

How to log all Magento 2 SQL queries?

bin/magento dev:query-log:enable . (copied my answer from Magento 2 log database queries)
Felix's user avatar
  • 999
36 votes
Accepted

How to log all Magento 2 SQL queries?

In your app/etc/di.xml, replace the line: <preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\Quiet"/> with <preference for="Magento\Framework\DB\...
Siju Joseph's user avatar
22 votes
Accepted

Magento 2.2 often extremely slow, 100% processor usage after setup:upgrade

TL;DR: Just switch on the config caches. Longer story: I've had the same issue and have been playing around a bit. Steps to reproduce (in developer mode): cache:disable setup:upgrade reload ...
BuzzJoe's user avatar
  • 336
19 votes
Accepted

List of not-used core modules that can be turn off with no harm

Here's a list of what I think the modules do, it might help knowing what you can try to disable. Important note: please check the module dependencies when disabling modules because some dependencies ...
Raphael at Digital Pianism's user avatar
17 votes
Accepted

How is magento 2 better than magento 1?

This question may be opinion based but I'm just going to enlight some results from the offical white paper regarding Magento 2 performance and scalability Test Configuration Magento Enterprise ...
Raphael at Digital Pianism's user avatar
15 votes

Magento 2: move the javascript to the end of the body

First create new module: Create Module Company/DeferJS registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE,...
Pratik's user avatar
  • 3,805
14 votes
Accepted

Magento 2: log slow queries

app/etc/di.xml has the following preference set <preference for="Magento\Framework\DB\LoggerInterface" type="Magento\Framework\DB\Logger\Quiet"/> Add your own module to change the preference ...
Kristof at Fooman's user avatar
13 votes
Accepted

How to optimize the query: the product qty bought with each of the products

PHP improvements One big improvement you could in your PHP code would be to avoid using fetchAll to fetch large result sets as it will cause a heavy demand on system and possibly networks resources. ...
Raphael at Digital Pianism's user avatar
13 votes
Accepted

Magento 2 : What is profiler, what is it's purpose and how can it be used?

We can use a built-in profiler with Magento to perform tasks such as analyzing performance. It can tell us in intricate detail which blocks of code are used in the loading of a slow page, and how ...
Shyam's user avatar
  • 1,690
10 votes
Accepted

Magento 2 running so slow on localhost development

I tried everything and the only thing it works is the virtual machine that provides bitnami. https://bitnami.com/stack/magento/virtual-machine Seriously, I don't know what has this vm, but goes ...
Marc Pont's user avatar
  • 1,453
8 votes
Accepted

SQL (sub)query performance

Problem It is a pity, but there is no simple solution for your query. There are multiple basic issues exists in your original queries, that require changing your approach in general: As more joins ...
Ivan Chepurnyi's user avatar
8 votes
Accepted

Magento 2: how to use the collection walk iterator?

Yes, it's possible! It's very similar to Magento 1, by the way. \Magento\Framework\Model\ResourceModel\Iterator has the walk function which will call your callback function for every single item, ...
Matheus Gontijo's user avatar
8 votes

List of not-used core modules that can be turn off with no harm

Theoretically you should be able to disable any module if you also disable the module's dependencies. You should be able to see all dependencies by running the cli command bin/magento info:...
Marius's user avatar
  • 198k
8 votes

How to log all Magento 2 SQL queries?

Alternative (to the answer of Siju Joseph), if you don't want to change your magento config, you can also configure mysql itself: activate slow.log and set it to 0 seconds. Therefore edit /etc/...
Jonas Hünig's user avatar
7 votes
Accepted

Most efficient way to get data in templates

Before I give my answer I believe you may have a problem in your code - sessions should always be called as a singleton. Thus, the line Mage::getModel('checkout/session') should be Mage::getSingleton('...
philwinkle's user avatar
  • 35.8k
7 votes

Magento2 Elastic Search Configuration Issue

Check if the required modules are installed and enabled. In my case (during an update from Magento 2.3 to Magento 2.4) the modules "Magento_Elasticsearch" and "Magento_Elasticsearch6&...
poebel's user avatar
  • 101
6 votes

Magento 1.9 checkout and cart very slow

you need to profile your cart/checkout code - enable default magento profiler or install Aoe Profiler. it will show you on what magento spends most of the time. possible solutions for slow magento ...
Konstantin Gerasimov's user avatar
6 votes

Magento 1: caching SQL queries using Magento cache

It is a bad idea to cache MySQL queries when you can optimize them. You might think that caching will solve performance issues. But in the end, it adds another layer of I/O calls in the system, that ...
Ivan Chepurnyi's user avatar
6 votes

Magento 2 running so slow on localhost development

disable CSS/JS merging and minifying: Stores > Configuration > CSS Settings (Javascript Settings) > Merge CSS (Merge JS) > NO Stores > Configuration > CSS Settings (Javascript ...
Konstantin Gerasimov's user avatar
6 votes

Magento 2 running so slow on localhost development

I found that developer mode disable everything - which was overkill. There's certain aspects I do wish to cache, such as translation. Thankfully in env.php you can still set which caches to use ...
MackieeE's user avatar
  • 232
6 votes

Magento 2: Using a Flat Catalog is Helpful for Performance?

There are 2 data models in magento: eav (default) and flat. EAV is a very angile model it allows user to add custom attributes as many is he likes, but the problem is that it stores the data in many ...
Moshe Shperling's user avatar
6 votes

Why my bin/magento setup:upgrade is really slow?

We have the same experience. After "DDL cache cleared successfully" you can wait a long time for the next step. We found out that we can increase the speed by moving the folder pub/media/catalog to ...
Max's user avatar
  • 61
6 votes

How to use Magento 2 cache?

Add the caching interface loading to the constructor. public function __construct( Magento\Framework\DataObjectFactory $dataObjectFactory, Magento\Framework\App\CacheInterface $cache, Magento\...
Saphal Jha's user avatar
  • 1,883
6 votes
Accepted

Is it worth paying for Litespeed + LiteMage Cache on a Magento 2 site, or can I do just as well with Varnish, Turpentine, Redis, etc.?

Should I believe any of those claims? You shouldn't believe any claims unless you can independently verify them. That said, it's easy to decipher why LiteSpeed could be somewhat faster than other ...
Danila Vershinin's user avatar
6 votes

Is it worth paying for Litespeed + LiteMage Cache on a Magento 2 site, or can I do just as well with Varnish, Turpentine, Redis, etc.?

Full disclosure: I work for a hosting company that regularly uses LiteSpeed, but we've worked with a lot of technologies and Magento, including Apache, Nginx, Varnish and so forth. In our experience, ...
Craig Luke's user avatar
5 votes
Accepted

Best practice/scalable way to mass update tier prices?

The best way to update tier prices in bulk (as any batch of data in Magento) is to use direct database communication approach. In your case I would do the following: Create a new temporary table into ...
Ivan Chepurnyi's user avatar
5 votes

ImportExport problem with new destructor of Varien_Image_Adapter_Gd2 in 1.9.2.0

So I did raise a bug with Magento including a "solution" that should deal with the memory usage issues in the image import process. The solution can be found on github under https://github.com/...
David Manners's user avatar
5 votes

Efficient get product url from id

I guess the most efficent way to get a products rewritten URL (w/o loading product) is to look directly on URL rewrite talbe. # returns string "product-url.html" $productUrl = Mage::getResourceModel('...
sv3n's user avatar
  • 11.7k
5 votes

Magento 2: how to use the collection walk iterator?

it still seems to be there: https://github.com/magento/magento2/blob/2.0/lib/internal/Magento/Framework/Model/ResourceModel/Iterator.php Usage should be the same as in M1
David Verholen's user avatar
5 votes
Accepted

Magento 1: using Mage::objects() to cache models

I have to admit, this is the first time I saw Mage::objects() and Varien_Object_Cache, but after looking at the code I think it was good like that. This should stay in the dark. There is too much ...
Fabian Schmengler's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible