<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sql on FromDual GmbH</title><link>https://www.fromdual.com/tags/sql/</link><description>Recent content in Sql on FromDual GmbH</description><generator>Hugo</generator><language>en-GB</language><managingEditor>oli.sennhauser@fromdual.com (Oli Sennhauser)</managingEditor><webMaster>oli.sennhauser@fromdual.com (Oli Sennhauser)</webMaster><copyright>© FromDual GmbH</copyright><lastBuildDate>Thu, 14 Mar 2024 12:06:39 +0000</lastBuildDate><atom:link href="https://www.fromdual.com/tags/sql/index.xml" rel="self" type="application/rss+xml"/><item><title>SQL Query Tuning - Performance</title><link>https://www.fromdual.com/blog/sql-query-tuning-performance/</link><pubDate>Mon, 05 Oct 2020 16:13:10 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/sql-query-tuning-performance/</guid><description>&lt;p&gt;How could the following SQL queries be improved performance wise and otherwise and can you also explain why your change is more optimal?&lt;/p&gt;</description></item><item><title>Creating synthetic data sets for tuning SQL queries</title><link>https://www.fromdual.com/blog/creating-synthetic-data-sets-for-tuning-sql-queries/</link><pubDate>Fri, 02 Oct 2020 16:50:33 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/creating-synthetic-data-sets-for-tuning-sql-queries/</guid><description>&lt;p&gt;When it comes to SQL Query tuning with customers we often get the slow running SQL query and possibly, in good cases, also the table structure. But very often, for various reasons, we do not get the data.&lt;/p&gt;</description></item><item><title>MariaDB SQL Error Log Plugin</title><link>https://www.fromdual.com/blog/mariadb-sql-error-log-plugin/</link><pubDate>Thu, 30 Jul 2020 12:26:18 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/mariadb-sql-error-log-plugin/</guid><description>&lt;p&gt;When you are for too long in business you think you know already everything and you are getting lazy. This happened to me again a few weeks ago. A customer asked me about the SQL Error Log Plugin. First I though he was talking about the MariaDB Error Log or the General Query Log. But then I have learned that there is something &amp;ldquo;new&amp;rdquo; I did not know yet&amp;hellip;&lt;/p&gt;</description></item><item><title>MariaDB/MySQL Stored Language Examples</title><link>https://www.fromdual.com/blog/mariadb-mysql-stored-language-examples/</link><pubDate>Thu, 19 Mar 2020 17:53:29 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/mariadb-mysql-stored-language-examples/</guid><description>&lt;p&gt;MariaDB/MySQL Stored Language is called &lt;a href="https://en.wikipedia.org/wiki/SQL/PSM" target="_blank" title="SQL/PSM"&gt;SQL/PSM&lt;/a&gt;.&lt;br&gt;
There are 4 different types of Stored Language: Stored Procedures, Stored Functions, Triggers and Events.&lt;/p&gt;</description></item><item><title>Enable General Query Log per Connection in MariaDB</title><link>https://www.fromdual.com/blog/enable-gerneral-quey-log-per-connection-in-mariadb/</link><pubDate>Wed, 10 Jul 2019 20:27:58 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/enable-gerneral-quey-log-per-connection-in-mariadb/</guid><description>&lt;p&gt;The &lt;a href="https://mariadb.com/kb/en/library/general-query-log/" target="_Blank" title="General Query Log"&gt;General Query Log&lt;/a&gt; in MariaDB is a Log (file or table) that logs every statement sent from the Application to the MariaDB Database Server from the Connect Command to the Quit Command. A simple example you can find here:&lt;/p&gt;</description></item><item><title>Why you should take care of MySQL data types</title><link>https://www.fromdual.com/blog/why-you-should-take-care-of-mysql-data-types/</link><pubDate>Wed, 25 May 2016 11:42:20 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/why-you-should-take-care-of-mysql-data-types/</guid><description>&lt;p&gt;A customer reported last month that MySQL does a full table scan (FTS) if a query was filtered by a &lt;code&gt;INT&lt;/code&gt; value on a &lt;code&gt;VARCHAR&lt;/code&gt; column. First I told him that this is not true any more because MySQL has fixed this behaviour long time ago. He showed me that I was wrong:&lt;/p&gt;</description></item><item><title>Impact of column types on MySQL JOIN performance</title><link>https://www.fromdual.com/blog/impact-of-column-types-on-mysql-join-performance/</link><pubDate>Wed, 11 Dec 2013 20:12:40 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/impact-of-column-types-on-mysql-join-performance/</guid><description>&lt;p&gt;In our &lt;a href="https://www.fromdual.com/mysql-training" target="FromDual MySQL Training"&gt;MySQL trainings&lt;/a&gt; and &lt;a href="https://www.fromdual.com/mysql-consulting" title="FromDual MySQL Consulting"&gt;consulting engagements&lt;/a&gt; we tell our customers always to use the &lt;a href="http://dev.mysql.com/doc/refman/5.6/en/storage-requirements.html" target="_blank" title="Data Type Storage Requirements"&gt;smallest possible data type&lt;/a&gt; to get better query performance. Especially for the &lt;code&gt;JOIN&lt;/code&gt; columns. This advice is supported as well by the MySQL documentation in the chapter &lt;a href="http://dev.mysql.com/doc/refman/5.6/en/optimize-data-types.html" target="_blank" title="MySQL documentation"&gt;Optimizing Data Types&lt;/a&gt;:&lt;/p&gt;</description></item><item><title>Last login of MySQL database users</title><link>https://www.fromdual.com/blog/last-login-off-mysql-database-users/</link><pubDate>Sat, 01 Dec 2012 10:05:50 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/last-login-off-mysql-database-users/</guid><description>&lt;p&gt;MySQL hosting providers can easily loose the overview over their customers and which user or schema is still in use and which not.&lt;/p&gt;</description></item><item><title>Example 1</title><link>https://www.fromdual.com/blog/example-01/</link><pubDate>Fri, 09 Dec 2011 10:07:51 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/example-01/</guid><description>&lt;pre&gt;&lt;code&gt;CREATE TABLE `order` (
 id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
, name VARCHAR(64) NOT NULL
) ENGINE = InnoDB;

INSERT INTO `order` VALUES
 (NULL, 'Test order 1')
, (NULL, 'Test order 2')
, (NULL, 'Test order 3');


CREATE TABLE pos (
 id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY
, order_id INT UNSIGNED NOT NULL
, name VARCHAR(64) NOT NULL
, amount SMALLINT NOT NULL
, price DECIMAL (6,2) NOT NULL
, status TINYINT NULL
) ENGINE = InnoDB;

INSERT INTO pos VALUES
 (null, 1, 'Schrauben', 50, 0.10, 0)
, (null, 1, 'Muttern', 50, 0.10, 0)
, (null, 2, 'Nägel', 1000, 0.05, 1);


CREATE TABLE pos_shadow LIKE pos;
ALTER TABLE pos_shadow ENGINE = MEMORY;
INSERT INTO pos_shadow SELECT * FROM pos;

delimiter //

CREATE TRIGGER upd BEFORE UPDATE ON pos
FOR EACH ROW
BEGIN
 UPDATE pos_shadow AS p
 JOIN `order` AS o ON o.id = p.order_id and o.id = NEW.order_id
 SET status = 1
 WHERE o.id = 1;
END;
//

delimiter ;

SELECT o.name, p.name, p.amount, p.price, (p.amount*p.price) AS total, p. status
 FROM `order` AS o
 JOIN pos_shadow AS p ON p.order_id = o.id
;

UPDATE pos AS p
 JOIN `order` AS o ON o.id = p.order_id AND o.id = 1
 SET p.status = 1, p.order_id = 1
 where o.id = 1;

SELECT o.name, p.name, p.amount, p.price, (p.amount*p.price) AS total, p. status
 FROM `order` AS o
 JOIN pos AS p on p.order_id = o.id
;
&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>How good is MySQL INSERT TRIGGER performance</title><link>https://www.fromdual.com/blog/how-good-is-mysql-insert-trigger-performance/</link><pubDate>Wed, 03 Aug 2011 17:08:36 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/how-good-is-mysql-insert-trigger-performance/</guid><description>&lt;p&gt;&lt;strong&gt;Abstract:&lt;/strong&gt; In this article we discuss how big is the performance impact of MySQL &lt;code&gt;TRIGGER&lt;/code&gt;s compared to application side logging (with &lt;code&gt;INSERT&lt;/code&gt;) into a MySQL table.&lt;/p&gt;</description></item><item><title>MySQL logon and logoff trigger for auditing</title><link>https://www.fromdual.com/blog/mysql-logon-and-logoff-trigger-for-auditing/</link><pubDate>Fri, 10 Dec 2010 23:23:51 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/mysql-logon-and-logoff-trigger-for-auditing/</guid><description>&lt;p&gt;&lt;a href="https://www.fromdual.com/mysql-logon-trigger"&gt;A while ago&lt;/a&gt; I did some research about MySQL audit functionality and logon a and logoff triggers. MySQL and MariaDB provide a logon trigger in the form of the init_connect variable but no logoff trigger where most of the work for auditing would be done. When we would have a logoff trigger we could track the login and possibility some activity of a user and implement auditing functionality.&lt;/p&gt;</description></item><item><title>Materialized Views with MySQL</title><link>https://www.fromdual.com/blog/mysql-materialized-views/</link><pubDate>Sat, 13 Mar 2010 13:55:05 +0000</pubDate><author>oli.sennhauser@fromdual.com (Oli Sennhauser)</author><guid>https://www.fromdual.com/blog/mysql-materialized-views/</guid><description>&lt;h2 id="table-of-contents"&gt;Table of Contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#what_is"&gt;What is a Materialized View?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#implement"&gt;Implement your own Materialized Views&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#refreshing"&gt;Refreshing materialized views&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#hands_on"&gt;Hands on&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#create_your_own"&gt;Create your own Materialized View:&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#refresh_on_demand"&gt;Refresh Materialized View on demand&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#refresh_immediate"&gt;Refresh Materialized View immediate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#snapshotting"&gt;Materialized Views with snapshotting functionality&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#benchmarks"&gt;Some performance benchmarks for our Materialized Views:&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#outlook"&gt;Outlook&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#conclusion"&gt;Conclusion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fromdual.com/blog/mysql-materialized-views/#literature"&gt;Literature&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span id="what_is"&gt;&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>