Comments on: Introduction to MySQL 8.0 Common Table Expressions (Part 1) https://www.percona.com/blog/introduction-to-mysql-8-0-common-table-expressions-part-1/ Thu, 13 Feb 2020 19:57:17 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: Corrado Pandiani https://www.percona.com/blog/introduction-to-mysql-8-0-common-table-expressions-part-1/#comment-10971817 Thu, 13 Feb 2020 19:57:17 +0000 https://www.percona.com/blog/?p=65069#comment-10971817 Hi, you’re right. It’s the same as the view. Even for CTE the optimizer can merge the CTE code or materialize it. The aim of the article was to show the usage and the benefit of CTE by the application perspective. Anyway it is worth considering to write anotehr article discussing about internals and the optimizer optimization when using CTE. Thanks

]]>
By: Øystein Grøvlen https://www.percona.com/blog/introduction-to-mysql-8-0-common-table-expressions-part-1/#comment-10971815 Thu, 13 Feb 2020 18:46:31 +0000 https://www.percona.com/blog/?p=65069#comment-10971815 Note that a CTE is not always materialized. Like a derived table, it may be merged into the main query if it does not contain aggregation, limit, union etc.

]]>
By: Corrado Pandiani https://www.percona.com/blog/introduction-to-mysql-8-0-common-table-expressions-part-1/#comment-10971806 Tue, 11 Feb 2020 14:49:49 +0000 https://www.percona.com/blog/?p=65069#comment-10971806 Hi Adnan. Basically the execution plan of a view and a CTE is the same if the derived query is referenced only once. The CTE will be significantly better than a view if the derived query is referenced more times. The CTE materialize the query at the beginning anche than can be referenced as many times you need. For the view is different. Any sinle reference of a derived table requires materialization. This involves more memiry usage and worse performance. I hope this helps.

]]>
By: Adnan https://www.percona.com/blog/introduction-to-mysql-8-0-common-table-expressions-part-1/#comment-10971796 Mon, 10 Feb 2020 20:08:04 +0000 https://www.percona.com/blog/?p=65069#comment-10971796 So can we take CTE as an alternative to View ? and what about memory efficiency in CTE ? is it efficient than View or standard sub queries ? if so, then it will give a big benefit on performance optimization.

]]>