<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>The Magento Expert</title>
	<atom:link href="https://www.the-mage-expert.com/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.the-mage-expert.com</link>
	<description>Your Magento Commerce Expert</description>
	<lastBuildDate>Thu, 05 Nov 2026 21:47:58 +0000</lastBuildDate>
	<language>de-DE</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.8.6</generator>
	<item>
		<title>Finding the Largest Database Tables Using SQL</title>
		<link>https://www.the-mage-expert.com/3222/finding-the-largest-database-tables-using-sql/</link>
		<comments>https://www.the-mage-expert.com/3222/finding-the-largest-database-tables-using-sql/#comments</comments>
		<pubDate>Fri, 16 Oct 2026 21:22:20 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Solutions]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">https://www.the-mage-expert.com/?p=3222</guid>
		<description><![CDATA[A Magento database can grow large over time. Before you investigate or delete individual tables, identify which tables consume the most space. The following SQL query lists the 20 largest tables, including data size, index size and total size: [crayon-6af33ff736fe2/]&#8230;]]></description>
				<content:encoded><![CDATA[<p>A Magento database can grow large over time. Before you investigate or delete individual tables, identify which tables consume the most space.</p>
<p>The following SQL query lists the 20 largest tables, including data size, index size and total size:</p><pre class="crayon-plain-tag">SELECT
    TABLE_NAME AS Table_Name,
    TABLE_ROWS AS Rows_Estimated,
    ROUND(DATA_LENGTH / 1024 / 1024, 2) AS Data_MB,
    ROUND(INDEX_LENGTH / 1024 / 1024, 2) AS Index_MB,
    ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024, 2) AS Total_MB,
    ROUND(DATA_LENGTH / 1024 / 1024 / 1024, 3) AS Data_GB,
    ROUND(INDEX_LENGTH / 1024 / 1024 / 1024, 3) AS Index_GB,
    ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024 / 1024, 3) AS Total_GB
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'YOUR_MAGENTO_DATABASE'
ORDER BY (DATA_LENGTH + INDEX_LENGTH) DESC
LIMIT 20;</pre><p><strong>YOUR_MAGENTO_DATABASE</strong> Replace this with the actual name of your Magento database. You can find it, for example, in <strong>app/etc/env.php</strong> under <strong>dbname</strong>.</p>
<p>The <strong>Total_MB</strong> and <strong>Total_GB</strong> are particularly useful because it includes data and indexes. This helps spot unusually large cron, quote, log or extension tables.</p>
<p>The column <strong>Rows_Estimated</strong> should be treated only as an approximate value for InnoDB. For locating especially large tables, <strong>DATA_LENGTH</strong> and <strong>INDEX_LENGTH</strong> are more important.</p>
<p>The query does not change any data and is a useful first check before investigating why your Magento database has grown so large.</p>]]></content:encoded>
			<wfw:commentRss>https://www.the-mage-expert.com/3222/finding-the-largest-database-tables-using-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding Slow Database Queries with the Query Log</title>
		<link>https://www.the-mage-expert.com/3196/finding-slow-database-queries-with-the-query-log/</link>
		<comments>https://www.the-mage-expert.com/3196/finding-slow-database-queries-with-the-query-log/#comments</comments>
		<pubDate>Tue, 13 Oct 2026 20:10:21 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Solutions]]></category>
		<category><![CDATA[Logging]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">https://www.the-mage-expert.com/?p=3196</guid>
		<description><![CDATA[When a Magento 2 store is slow, PHP, Redis and Varnish are not always to blame. Individual slow database queries can also make certain pages or processes much slower than expected. Magento 2 includes a Query Log that you can&#8230;]]></description>
				<content:encoded><![CDATA[<p>When a Magento 2 store is slow, PHP, Redis and Varnish are not always to blame. Individual slow database queries can also make certain pages or processes much slower than expected.</p>
<p>Magento 2 includes a <strong>Query Log</strong> that you can enable directly from the CLI:</p><pre class="crayon-plain-tag">bin/magento dev:query-log:enable</pre><p>Recorded queries are written to <strong>var/debug/db.log</strong> and can be followed live with:</p><pre class="crayon-plain-tag">tail -f var/debug/db.log</pre><p>If you do not want to log every small query, Magento can also record only those above a given duration:</p><pre class="crayon-plain-tag">bin/magento dev:query-log:enable \
--include-all-queries=false \
--query-time-threshold=0.5 \
--include-call-stack=true</pre><p>In this example, only database queries taking at least <strong>0.5 seconds</strong> are logged. The <strong>include-call-stack</strong> option also records the call stack, helping you identify which module or code triggered a slow query.</p>
<p>Especially for slow product pages, imports, cron jobs and custom extensions, this can reveal whether one database query is the bottleneck.</p>
<p>Disable the query log again after your analysis:</p><pre class="crayon-plain-tag">bin/magento dev:query-log:disable</pre><p>With call stack logging enabled, the file may otherwise grow very quickly.</p>]]></content:encoded>
			<wfw:commentRss>https://www.the-mage-expert.com/3196/finding-slow-database-queries-with-the-query-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding products without product images using SQL</title>
		<link>https://www.the-mage-expert.com/3093/finding-products-without-product-images-using-sql/</link>
		<comments>https://www.the-mage-expert.com/3093/finding-products-without-product-images-using-sql/#comments</comments>
		<pubDate>Fri, 25 Sep 2026 20:47:23 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Solutions]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[product]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">https://www.the-mage-expert.com/?p=3093</guid>
		<description><![CDATA[Sometimes you need to find all products without assigned images in Magento 2, for example to verify that a product import or data migration is complete. The following SQL query returns products without product images: [crayon-6af33ff74b65c/]]]></description>
				<content:encoded><![CDATA[<p>Sometimes you need to find all products without assigned images in Magento 2, for example to verify that a product import or data migration is complete.</p>
<p>The following SQL query returns products without product images:</p><pre class="crayon-plain-tag">SELECT
    p.entity_id,
    p.sku,
    p.type_id
FROM catalog_product_entity AS p
LEFT JOIN catalog_product_entity_media_gallery_value_to_entity AS mg
    ON mg.entity_id = p.entity_id
WHERE mg.value_id IS NULL
ORDER BY p.entity_id;</pre><p></p>]]></content:encoded>
			<wfw:commentRss>https://www.the-mage-expert.com/3093/finding-products-without-product-images-using-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting orders directly from the database with SQL</title>
		<link>https://www.the-mage-expert.com/2474/deleting-orders-directly-from-the-database-with-sql/</link>
		<comments>https://www.the-mage-expert.com/2474/deleting-orders-directly-from-the-database-with-sql/#comments</comments>
		<pubDate>Tue, 11 Feb 2025 09:56:50 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Solutions]]></category>
		<category><![CDATA[Magento 2]]></category>
		<category><![CDATA[order]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">https://www.the-mage-expert.com/?p=2474</guid>
		<description><![CDATA[Deleting large numbers of orders from Magento 2 admin often causes timeouts. You can also delete orders directly through the database. Open phpMyAdmin and run the following two statements: Proceed at your own risk. Test on a staging system or&#8230;]]></description>
				<content:encoded><![CDATA[<p>Deleting large numbers of orders from Magento 2 admin often causes timeouts. You can also delete orders directly through the database. Open phpMyAdmin and run the following two statements:</p>
<p><em>Proceed at your own risk. Test on a staging system or at least make a complete database backup first!</em></p><pre class="crayon-plain-tag">DELETE FROM sales_order WHERE ... ;
DELETE FROM sales_order_grid WHERE ... ;</pre><p>Clear the Magento 2 cache afterwards and verify that the intended orders were removed. </p>]]></content:encoded>
			<wfw:commentRss>https://www.the-mage-expert.com/2474/deleting-orders-directly-from-the-database-with-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing the Mage_Core_Model_Store::setWebsite() argument type error</title>
		<link>https://www.the-mage-expert.com/1172/fixing-the-mage-core-model-store-setwebsite-argument-type-error/</link>
		<comments>https://www.the-mage-expert.com/1172/fixing-the-mage-core-model-store-setwebsite-argument-type-error/#comments</comments>
		<pubDate>Mon, 02 May 2016 06:55:25 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Solutions]]></category>
		<category><![CDATA[error messages]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">https://www.the-mage-expert.com/?p=1172</guid>
		<description><![CDATA[You might encounter the message Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website, null given when moving your store to another server. The solution is straightforward. Run the following SQL queries to resolve the issue: [crayon-6af33ff74bd4b/]]]></description>
				<content:encoded><![CDATA[<p>You might encounter the message <strong>Argument 1 passed to Mage_Core_Model_Store::setWebsite() must be an instance of Mage_Core_Model_Website, null given</strong> when moving your store to another server.</p>
<p>The solution is straightforward. Run the following SQL queries to resolve the issue:</p>
<p></p><pre class="crayon-plain-tag">SET FOREIGN_KEY_CHECKS=0;
UPDATE core_store_group SET group_id = 0 WHERE name = 'Default';
UPDATE core_store SET store_id = 0 WHERE code = 'admin';
UPDATE core_website SET website_id = 0 WHERE code = 'admin';
UPDATE customer_group SET customer_group_id = 0 WHERE customer_group_code = 'NOT LOGGED IN';
SET FOREIGN_KEY_CHECKS=1;</pre><p></p>]]></content:encoded>
			<wfw:commentRss>https://www.the-mage-expert.com/1172/fixing-the-mage-core-model-store-setwebsite-argument-type-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting all products using SQL</title>
		<link>https://www.the-mage-expert.com/1045/magento-deleting-all-products-using-sql/</link>
		<comments>https://www.the-mage-expert.com/1045/magento-deleting-all-products-using-sql/#comments</comments>
		<pubDate>Thu, 10 Mar 2016 10:08:01 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Magento Solutions]]></category>
		<category><![CDATA[product]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">https://www.the-mage-expert.com/?p=1045</guid>
		<description><![CDATA[To delete all product related data, use the following query: DELETE FROM catalog_product_entity; Due to the constraints it will delete all related data from other tables as well.]]></description>
				<content:encoded><![CDATA[<p>To delete all product related data, use the following query:</p>
<pre lang="sql">
DELETE FROM catalog_product_entity;
</pre>
<p>Due to the constraints it will delete all related data from other tables as well. </p>]]></content:encoded>
			<wfw:commentRss>https://www.the-mage-expert.com/1045/magento-deleting-all-products-using-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting all products using SQL</title>
		<link>https://www.the-mage-expert.com/1092/deleting-all-products-using-sql/</link>
		<comments>https://www.the-mage-expert.com/1092/deleting-all-products-using-sql/#comments</comments>
		<pubDate>Tue, 23 Feb 2016 09:17:01 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Solutions]]></category>
		<category><![CDATA[product]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">https://www.the-mage-expert.com/?p=1092</guid>
		<description><![CDATA[Want to remove all products from your Magento store directly through the database? The following statement removes the products and their related data: [crayon-6af33ff74c0b9/] Thanks to the constraints on this table, product relationships are also removed from the relevant tables.]]></description>
				<content:encoded><![CDATA[<p>Want to remove all products from your Magento store directly through the database? The following statement removes the products and their related data:</p>
<p></p><pre class="crayon-plain-tag">DELETE FROM catalog_product_entity;</pre><p></p>
<p>Thanks to the constraints on this table, product relationships are also removed from the relevant tables.</p>]]></content:encoded>
			<wfw:commentRss>https://www.the-mage-expert.com/1092/deleting-all-products-using-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting products with or without custom options using SQL</title>
		<link>https://www.the-mage-expert.com/1005/magento-getting-products-with-or-without-custom-options-using-sql/</link>
		<comments>https://www.the-mage-expert.com/1005/magento-getting-products-with-or-without-custom-options-using-sql/#comments</comments>
		<pubDate>Fri, 15 Jan 2016 01:22:07 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Magento Solutions]]></category>
		<category><![CDATA[custom options]]></category>
		<category><![CDATA[product]]></category>
		<category><![CDATA[products]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">https://www.the-mage-expert.com/?p=1005</guid>
		<description><![CDATA[To get all products that do not have custom options, simply run the following SQL query: SELECT * FROM catalog_product_entity WHERE entity_id NOT IN (SELECT DISTINCT product_id FROM catalog_product_option); To get all products that do have custom options, remove the&#8230;]]></description>
				<content:encoded><![CDATA[<p>To get all products that <strong>do not</strong> have custom options, simply run the following SQL query: </p>
<pre lang="sql">
SELECT
  *
FROM catalog_product_entity
WHERE entity_id NOT IN (SELECT DISTINCT
    product_id
  FROM catalog_product_option);
</pre>
<p>To get all products that do have custom options, remove the &#8220;NOT&#8221; from the above query.</p>]]></content:encoded>
			<wfw:commentRss>https://www.the-mage-expert.com/1005/magento-getting-products-with-or-without-custom-options-using-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding products with and without custom options using SQL</title>
		<link>https://www.the-mage-expert.com/1034/finding-products-with-and-without-custom-options-using-sql/</link>
		<comments>https://www.the-mage-expert.com/1034/finding-products-with-and-without-custom-options-using-sql/#comments</comments>
		<pubDate>Fri, 15 Jan 2016 00:51:46 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Solutions]]></category>
		<category><![CDATA[custom options]]></category>
		<category><![CDATA[product]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">https://www.the-mage-expert.com/?p=1034</guid>
		<description><![CDATA[To find all products that have keine no custom options, run this query: [crayon-6af33ff74c3f9/] To find all products that do have custom options, simply remove &#8220;NOT&#8221; from the query above.]]></description>
				<content:encoded><![CDATA[<p>To find all products that have <strong>keine</strong> no custom options, run this query:</p><pre class="crayon-plain-tag">SELECT
  *
FROM catalog_product_entity
WHERE entity_id NOT IN (SELECT DISTINCT
    product_id
  FROM catalog_product_option);</pre><p></p>
<p>To find all products that do have custom options, simply remove &#8220;NOT&#8221; from the query above.</p>]]></content:encoded>
			<wfw:commentRss>https://www.the-mage-expert.com/1034/finding-products-with-and-without-custom-options-using-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing the admin password directly in the database using SQL</title>
		<link>https://www.the-mage-expert.com/989/changing-the-admin-password-directly-in-the-database-using-sql/</link>
		<comments>https://www.the-mage-expert.com/989/changing-the-admin-password-directly-in-the-database-using-sql/#comments</comments>
		<pubDate>Thu, 29 Oct 2015 07:34:03 +0000</pubDate>
		<dc:creator><![CDATA[Mex]]></dc:creator>
				<category><![CDATA[Magento Solutions]]></category>
		<category><![CDATA[Admin]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">https://www.the-mage-expert.com/?p=989</guid>
		<description><![CDATA[Use the following SQL statement to reset an administrator&#8217;s password directly in the database: [crayon-6af33ff74c6fa/]]]></description>
				<content:encoded><![CDATA[<p>Use the following SQL statement to reset an administrator&#8217;s password directly in the database:</p>
<p></p><pre class="crayon-plain-tag">UPDATE `admin_user` SET `password` = MD5('NEUESPASSWORT') WHERE `username` = 'ADMINUSERNAME';</pre><p></p>]]></content:encoded>
			<wfw:commentRss>https://www.the-mage-expert.com/989/changing-the-admin-password-directly-in-the-database-using-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
