<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>MySQL Forums - Optimizer &amp; Parser</title>
        <description>Forum for MySQL Optimizer &amp; Parser.</description>
        <link>https://forums.mysql.com/list.php?115</link>
        <lastBuildDate>Tue, 21 Apr 2026 11:17:51 +0000</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://forums.mysql.com/read.php?115,730578,730578#msg-730578</guid>
            <title>MySQL:  New JSON format for EXPLAIN (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,730578,730578#msg-730578</link>
            <description><![CDATA[ MySQL:  New JSON format for EXPLAIN<br />
- <a href="https://blogs.oracle.com/mysql/post/new-json-format-for-explain"  rel="nofollow">https://blogs.oracle.com/mysql/post/new-json-format-for-explain</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Mon, 04 Nov 2024 16:22:09 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,710723,710723#msg-710723</guid>
            <title>MySQL:  EXPLAIN INTO and EXPLAIN FOR SCHEMA (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,710723,710723#msg-710723</link>
            <description><![CDATA[ MySQL:  EXPLAIN INTO and EXPLAIN FOR SCHEMA<br />
-  <a href="https://blogs.oracle.com/mysql/post/explain-into-and-explain-for-schema-in-mysql-81-and-82"  rel="nofollow">https://blogs.oracle.com/mysql/post/explain-into-and-explain-for-schema-in-mysql-81-and-82</a><br />
<br />
MySQL:  EXPLAIN ANALYZE<br />
- <a href="https://hackmysql.com/post/book-2/"  rel="nofollow">https://hackmysql.com/post/book-2/</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Fri, 24 Nov 2023 18:34:31 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,709742,709742#msg-709742</guid>
            <title>MySQL EXPLAIN ANALYZE (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,709742,709742#msg-709742</link>
            <description><![CDATA[ MySQL EXPLAIN ANALYZE:  <br />
- <a href="https://hackmysql.com/post/book-2/"  rel="nofollow">https://hackmysql.com/post/book-2/</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Wed, 09 Aug 2023 23:43:35 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,709741,709741#msg-709741</guid>
            <title>MySQL Deferred Join: A Deep Dive (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,709741,709741#msg-709741</link>
            <description><![CDATA[ MySQL Deferred Join: A Deep Dive<br />
- <a href="https://hackmysql.com/post/deferred-join-deep-dive/"  rel="nofollow">https://hackmysql.com/post/deferred-join-deep-dive/</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Wed, 09 Aug 2023 23:28:31 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,707404,707404#msg-707404</guid>
            <title>Why multi-valued index is not in possible keys in a dependent subquery (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,707404,707404#msg-707404</link>
            <description><![CDATA[ -- DDL<br />
create table scholardata_journal<br />
(<br />
    id                int auto_increment primary key,<br />
    sci_if            double null,<br />
    issn_list         json default (_utf8mb4&#039;[]&#039;) not null<br />
);<br />
<br />
create index issn_list_multi_value_index<br />
    on journal ((cast(`issn_list` as char(15) array)));<br />
<br />
create table userlibrary_biblio<br />
(<br />
    id                         int auto_increment primary key,<br />
    user_id                    int NOT NULL,<br />
    issn                       varchar(50) not null,<br />
<br />
    constraint userlibrary_biblio_user_id_ecab5d00_fk_auth_user_id<br />
        foreign key (user_id) references ivy.auth_user (id)<br />
);<br />
<br />
-- SELECT in subquery<br />
select id,<br />
       issn,<br />
       (<br />
           IF(userlibrary_biblio.issn = &#039;&#039;, null, (select sci_if<br />
                                                   from scholardata_journal<br />
                                                   where userlibrary_biblio.issn member of(scholardata_journal.issn_list)<br />
                                                   limit 1))<br />
           ) as sci_if<br />
from userlibrary_biblio where user_id = 28;<br />
<br />
<br />
---<br />
Explain result:<br />
<br />
-&gt; Index lookup on userlibrary_biblio using userlibrary_biblio_user_id_ecab5d00_fk_auth_user_id (user_id=28)  (cost=260.78 rows=254) (actual time=0.098..1.185 rows=254 loops=1)<br />
-&gt; Select #2 (subquery in projection; dependent)<br />
    -&gt; Limit: 1 row(s)  (cost=5875.65 rows=1) (actual time=19.485..19.486 rows=1 loops=84)<br />
        -&gt; Filter: userlibrary_biblio.issn member of (scholardata_journal.issn_list)  (cost=5875.65 rows=56274) (actual time=19.485..19.485 rows=1 loops=84)<br />
            -&gt; Table scan on scholardata_journal  (cost=5875.65 rows=56274) (actual time=0.005..13.855 rows=22979 loops=84)]]></description>
            <dc:creator>ELON ZHOU</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Fri, 03 Feb 2023 04:01:24 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,707238,707238#msg-707238</guid>
            <title>MySQL Hypergraph Optimizer for HeatWave (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,707238,707238#msg-707238</link>
            <description><![CDATA[ MySQL Hypergraph Optimizer for HeatWave<br />
- <a href="https://blogs.oracle.com/mysql/post/fast-query-performance-with-mysql-hypergraph-optimizer-for-heatwave"  rel="nofollow">https://blogs.oracle.com/mysql/post/fast-query-performance-with-mysql-hypergraph-optimizer-for-heatwave</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Tue, 17 Jan 2023 15:20:37 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,706806,706806#msg-706806</guid>
            <title>what does explain ref const, const means ? (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,706806,706806#msg-706806</link>
            <description><![CDATA[ I executed explain a select query.<br />
the result shows two const, const for in a ref column.<br />
what does two const, const means ?<br />
does explain reads twice table ?<br />
<br />
Please help me.]]></description>
            <dc:creator>jongse park</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Wed, 23 Nov 2022 06:00:50 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,706629,706629#msg-706629</guid>
            <title>Set Theory in MySQL 8.0: UNION and Now INTERSECT and EXCEPT (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,706629,706629#msg-706629</link>
            <description><![CDATA[ <a href="https://www.percona.com/blog/set-theory-in-mysql-8-0-union-and-now-intersect-and-except/"  rel="nofollow">https://www.percona.com/blog/set-theory-in-mysql-8-0-union-and-now-intersect-and-except/</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Wed, 02 Nov 2022 16:25:28 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,706531,706531#msg-706531</guid>
            <title>Plugin For Obtaining Tokenized Query (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,706531,706531#msg-706531</link>
            <description><![CDATA[ Dear Community, <br />
I need for a private project to get from the mysql database any query, that is processed, in a tokenized form.<br />
<br />
Example:<br />
Select * from users where 1 = 1;<br />
Desired Output: <br />
[&quot;Select&quot;, &quot;*&quot;, &quot;from&quot;, &quot;users&quot;, &quot;where&quot;, &quot;1&quot;, &quot;=&quot;, &quot;1&quot;]<br />
<br />
<br />
I started developing a PoC by implementing a simple query rewrite plugin. Currently I want to call the &#039;get_command&#039; method of a MYSQL_THD object. However,<br />
every time I try to compile my plugin it gives me the following error<br />
<br />
&#039;error: invalid use of incomplete type ‘class THD’&#039; <br />
<br />
I have included the following files in my plugin:<br />
#include &lt;my_global.h&gt;<br />
#include &lt;mysql/plugin.h&gt;<br />
#include &lt;mysql/plugin_audit.h&gt;<br />
#include &lt;mysql/service_mysql_alloc.h&gt;<br />
#include &lt;mysql/services.h&gt;<br />
#include &lt;mysql/service_parser.h&gt;<br />
#include &lt;mysql/mysql_lex_string.h&gt;<br />
#include &lt;sql_class.h&gt;<br />
<br />
The following snippet is my code: <br />
<br />
if (event_class == MYSQL_AUDIT_PARSE_CLASS)<br />
  {<br />
    const struct mysql_event_parse *event_parse=<br />
      static_cast&lt;const struct mysql_event_parse *&gt;(event);<br />
<br />
    if (event_parse-&gt;event_subclass == MYSQL_AUDIT_PARSE_POSTPARSE)<br />
    {<br />
      thd-&gt;get_command();<br />
    }<br />
  }<br />
<br />
However, it still wont compile. What header file am I missing or better question why can&#039;t I access any variable or method of the MYSQL_THD object.<br />
<br />
I hope this is the right place for this question and hope that you guys can help me :)]]></description>
            <dc:creator>JustADude Tester</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Wed, 19 Oct 2022 14:23:09 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,706322,706322#msg-706322</guid>
            <title>Why MySQL adding 1 when calculating the records per key? (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,706322,706322#msg-706322</link>
            <description><![CDATA[ When calculating the records per key, we see the MySQL using the &quot;rec_per_key_t(tab-&gt;records()) / distinct_keys_est + 1;&quot; ,my question is why it doesn&#039;t use the &quot;rec_per_key_t(tab-&gt;records()) / distinct_keys_est ;&quot; instead ,why it needs the &quot;+ 1&quot; here?<br />
<br />
The code segment is below:<br />
<br />
       /*<br />
          Assume that the first key part matches 1% of the file<br />
          and that the whole key matches 10 (duplicates) or 1<br />
          (unique) records.<br />
          Assume also that more key matches proportionally more<br />
          records<br />
          This gives the formula:<br />
          records = (x * (b-a) + a*c-b)/(c-1)<br />
<br />
          b = records matched by whole key<br />
          a = records matched by first key part (1% of all records?)<br />
          c = number of key parts in key<br />
          x = used key parts (1 &lt;= x &lt;= c)<br />
        */<br />
        rec_per_key_t rec_per_key;<br />
        if (keyinfo-&gt;has_records_per_key(<br />
              keyinfo-&gt;user_defined_key_parts - 1))<br />
          rec_per_key=<br />
            keyinfo-&gt;records_per_key(keyinfo-&gt;user_defined_key_parts - 1);<br />
           else<br />
          rec_per_key=<br />
            rec_per_key_t(tab-&gt;records()) / distinct_keys_est + 1;<br />
<br />
<a href="https://github.com/mysql/mysql-server/blob/5.7/sql/sql_planner.cc#L556"  rel="nofollow">https://github.com/mysql/mysql-server/blob/5.7/sql/sql_planner.cc#L556</a>]]></description>
            <dc:creator>yufeng shen</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Sun, 25 Sep 2022 01:16:34 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,706321,706321#msg-706321</guid>
            <title>Why MySQL adding 1 when calculating the records per key? (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,706321,706321#msg-706321</link>
            <description><![CDATA[ When calculating the records per key, we see the MySQL using the &quot;rec_per_key_t(tab-&gt;records()) / distinct_keys_est + 1;&quot; ,my question is why it doesn&#039;t use the &quot;rec_per_key_t(tab-&gt;records()) / distinct_keys_est ;&quot; instead ,why it needs the &quot;+ 1&quot; here?<br />
<br />
The code segment is below:<br />
<br />
       /*<br />
          Assume that the first key part matches 1% of the file<br />
          and that the whole key matches 10 (duplicates) or 1<br />
          (unique) records.<br />
          Assume also that more key matches proportionally more<br />
          records<br />
          This gives the formula:<br />
          records = (x * (b-a) + a*c-b)/(c-1)<br />
<br />
          b = records matched by whole key<br />
          a = records matched by first key part (1% of all records?)<br />
          c = number of key parts in key<br />
          x = used key parts (1 &lt;= x &lt;= c)<br />
        */<br />
        rec_per_key_t rec_per_key;<br />
        if (keyinfo-&gt;has_records_per_key(<br />
              keyinfo-&gt;user_defined_key_parts - 1))<br />
          rec_per_key=<br />
            keyinfo-&gt;records_per_key(keyinfo-&gt;user_defined_key_parts - 1);<br />
           else<br />
          rec_per_key=<br />
            rec_per_key_t(tab-&gt;records()) / distinct_keys_est + 1;<br />
<br />
<br />
The code segment above can be found here:<br />
<a href="https://github.com/mysql/mysql-server/blob/5.7/sql/sql_planner.cc#L556"  rel="nofollow">https://github.com/mysql/mysql-server/blob/5.7/sql/sql_planner.cc#L556</a>]]></description>
            <dc:creator>yufeng shen</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Sun, 25 Sep 2022 01:10:01 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,706150,706150#msg-706150</guid>
            <title>MYSQL5.7:OPTIMIZER  Contradict Explain (1 reply)</title>
            <link>https://forums.mysql.com/read.php?115,706150,706150#msg-706150</link>
            <description><![CDATA[ MYSQL5.7:OPTIMIZER  Contradict Explain<br />
example1:<br />
Index：ALTER TABLE t_app_recommended_info ADD INDEX idx_uid_create_time_type (uid,create_time,type);<br />
SQL：select * from t_app_recommended_info where uid = 1252057754179211264 and create_time &gt;&#039;2022-09-01 00:00:00&#039; and type =1 and params like &#039;%&quot;couponId&quot;:12582268875%&#039; and params like &#039;%&quot;hmsr&quot;:&quot;saomaqudao&quot;%&#039;;<br />
explain:key-len=12<br />
<br />
OPTIMIZER_TRACE:refine_plan: &quot;pushed_index_condition&quot;: &quot;((`t_app_recommended_info`.`type` = 1) and (`t_app_recommended_info`.`uid` = 1252057754179211264) and (`t_app_recommended_info`.`create_time` &gt; &#039;2022-09-01 00:00:00&#039;))&quot;,<br />
example2:<br />
Index：ALTER TABLE t_app_recommended_info ADD INDEX idx_uid_type_createtime (uid,type,create_time);<br />
SQL：select * from t_app_recommended_info where uid = 1252057754179211264 and create_time &gt;&#039;2022-09-01 00:00:00&#039; and type =1 and params like &#039;%&quot;couponId&quot;:12582268875%&#039; and params like &#039;%&quot;hmsr&quot;:&quot;saomaqudao&quot;%&#039;;<br />
explain:key-len=16<br />
<br />
OPTIMIZER_TRACE:refine_plan: &quot;pushed_index_condition&quot;: &quot;((`t_app_recommended_info`.`type` = 1) and (`t_app_recommended_info`.`uid` = 1252057754179211264) and (`t_app_recommended_info`.`create_time` &gt; &#039;2022-09-01 00:00:00&#039;))&quot;,<br />
example1 compair example2 [explain key-len] find type（4byte）not used，but OPTIMIZER_TRACE:refine_plan: find user index&#039; type，help.]]></description>
            <dc:creator>yijie fu</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Wed, 07 Sep 2022 11:26:59 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,705048,705048#msg-705048</guid>
            <title>Need help with getting rid of filesort (1 reply)</title>
            <link>https://forums.mysql.com/read.php?115,705048,705048#msg-705048</link>
            <description><![CDATA[ I have a pretty simple select query that the optimizer insists on using filesort for.<br />
<br />
EXPLAIN SELECT<br />
	`id`, `displayName`, `order`<br />
FROM<br />
	`someTable`<br />
WHERE<br />
	`id` != 0<br />
ORDER BY<br />
	`displayName`, `order`<br />
LIMIT<br />
	123456, 1000<br />
<br />
`id` is PK.<br />
<br />
`displayName` and `order` have their own indexes.<br />
<br />
I also have a ( `displayName`, `order` ) index as well as a ( `displayName`, `order`, `id` ) index.<br />
<br />
The optimizer still insists on using filesort.  If I add a FORCE INDEX to force it to use the ( `displayName`, `order` ) index, it works and runs much faster (50x faster).  If I remove the WHERE clause, the filesort goes away.  How can I properly set up this table / indexes so that I can have that where clause, and the optimizer would not use filesort?<br />
<br />
Thanks for any help!]]></description>
            <dc:creator>Marvin Herbold</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Fri, 24 Jun 2022 15:59:23 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,703191,703191#msg-703191</guid>
            <title>MySQL 8.0 EXPLAIN ANALYZE (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,703191,703191#msg-703191</link>
            <description><![CDATA[ MySQL EXPLAIN ANALYZE is an indispensable tool for understanding query execution because it breaks down the query execution stage of response time by measuring each step of the query execution plan. The information is illuminating, but the output is not intuitive: it requires practice and some understanding of how MySQL executes queries beyond the table join order shown by traditional EXPLAIN output. This blog post closely examines three different examples of EXPLAIN ANALYZE output.<br />
<a href="https://hackmysql.com/post/book-2/"  rel="nofollow">https://hackmysql.com/post/book-2/</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Mon, 28 Feb 2022 04:37:40 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,701654,701654#msg-701654</guid>
            <title>Startup was very slow (5 replies)</title>
            <link>https://forums.mysql.com/read.php?115,701654,701654#msg-701654</link>
            <description><![CDATA[ Hi,<br />
<br />
I tried to open this bug ( <a href="https://bugs.mysql.com/bug.php?id=106269&amp;thanks=2&amp;notify=67"  rel="nofollow">https://bugs.mysql.com/bug.php?id=106269&amp;thanks=2&amp;notify=67</a> ) that has been happening for a long time since a 5.7.x relase that I don&#039;t remember anymore, but it wasn&#039;t accepted I don&#039;t know why.<br />
<br />
The team said that there are adjustments that can improve this reading time of the .ibd files, I&#039;ve tried everything but until today it doesn&#039;t improve the time it just gets worse.<br />
<br />
Does anyone know what can be done on windows so that MySQL does not take more than 1h to go up?<br />
<br />
Thank you so much.]]></description>
            <dc:creator>Charles Rodrigues</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Sun, 09 Oct 2022 15:24:16 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,701528,701528#msg-701528</guid>
            <title>Optimizer in 8.0 in some cases not materializing subquery (1 reply)</title>
            <link>https://forums.mysql.com/read.php?115,701528,701528#msg-701528</link>
            <description><![CDATA[ We have a query that went from taking 2 seconds in MySQL 5.7 to 50+ seconds in 8.0. It appears it has to do with how the optimizer is handling some subqueries.<br />
<br />
Example of query:<br />
<br />
SELECT e.id, e.status_id, COUNT(e.id) AS cnt<br />
FROM Events e<br />
WHERE e.ent_id IN (1)<br />
AND<br />
NOT EXISTS<br />
(<br />
     SELECT eam.account<br />
     FROM EventAccountMapping eam<br />
     WHERE <br />
       eam.event_id = e.id AND<br />
       eam.account NOT IN<br />
       (<br />
            SELECT uapt.account<br />
            FROM UserAccountPermissions uapt<br />
            WHERE uapt.user_id = 1<br />
       ) /* Subquery 2 */<br />
)<br />
<br />
In 5.7, it was treating Subquery 2 as a subquery, and in 5.8, it&#039;s be treated as a dependent subquery, even though it is not dependent on the other tables<br />
<br />
If I break this into 2 queries where the select from UserAccountPermissions saves the results in a temp table, and then use that temp table, it goes from 50 seconds to 2. If I actually generate the results fo subquery 2, and inline the results ( &#039;aaa&#039;, &#039;bbbb&#039;, &#039;cccc&#039;, etc), the query goes down to less than one second.<br />
<br />
In 5.8, I moved the subquery 2 to a CTE, and that doesn&#039;t resolve the issue either. Is there a way to force a CTE to get materialized?]]></description>
            <dc:creator>Benjamin Peikes</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Mon, 24 Jan 2022 22:45:19 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,699473,699473#msg-699473</guid>
            <title>Running sql in server is too much slower then laptop (3 replies)</title>
            <link>https://forums.mysql.com/read.php?115,699473,699473#msg-699473</link>
            <description><![CDATA[ I use the same db data( import to server from my laptop&#039;s mysqldump), same mysql version 5.7.0,   <br />
   The server&#039;s CPU is Xeon E5-2670 v3 2.3GHz, with 8G RAM, while laptop&#039;s is just i7-8565U 1.8GHz，with 8G RAM.<br />
   But running same sql in server is much slower then laptop.<br />
   For example, to run this sql &quot;update a , b set a.tid=b.tid, a.tname=b.tname where a.m=b.m and  (a.tid&lt;&gt;b.tid or a.tname&lt;&gt;b.tname)&quot;, server used 756 seconds, but only 2.7 seconds in my laptop. Table a has 550K rows data. Table b has 207 rows data.  <br />
   It&#039;s very strange and I don&#039;t know how to optimize in server mysql. Our application can&#039;t run well in server because it&#039;s too slow.<br />
<br />
   Could you help me identify what reasons may cause this problem?]]></description>
            <dc:creator>Herems Jing</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Sun, 14 Nov 2021 03:21:28 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,699109,699109#msg-699109</guid>
            <title>Query optimization on LIKE (1 reply)</title>
            <link>https://forums.mysql.com/read.php?115,699109,699109#msg-699109</link>
            <description><![CDATA[ We have a simple query like this in mysql:<br />
<br />
SELECT<br />
<br />
ps.productType,<br />
<br />
COUNT(DISTINCT ps.some_other_id)<br />
<br />
FROM<br />
<br />
product_sum ps<br />
<br />
WHERE ps.customerId = &#039;abc&#039;<br />
<br />
AND ps.partitionId = &#039;bbc&#039;<br />
<br />
AND ps.orderId LIKE &quot;%123456%&quot;<br />
<br />
GROUP BY ps.productType;<br />
<br />
orderId field could be one id or multiple ids concat in this format: 123456,234567,345678<br />
<br />
<br />
<br />
We can&#039;t remove the leading % in the LIKE condition since the orderId could have multiple ids in the string. Mysql is not using indexing on orderId column since it has NULL value. Tried the FullText index but it cannot be used in partitioned table and also not able to combine with other indexes. Is there any other way it can be optimized? Please advise. Thank you.]]></description>
            <dc:creator>Sing Lau</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Mon, 04 Oct 2021 19:08:41 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,698716,698716#msg-698716</guid>
            <title>Run ANALYZE TABLE — Do Not Rely on InnoDB&#039;s Automatic Recalculation of Statistics (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,698716,698716#msg-698716</link>
            <description><![CDATA[ <a href="http://oysteing.blogspot.com/2021/09/run-analyze-table-do-not-rely-on.html"  rel="nofollow">http://oysteing.blogspot.com/2021/09/run-analyze-table-do-not-rely-on.html</a><br />
<br />
<a href="https://mysql.wisborg.dk/2021/08/22/automatic-update-of-innodb-persistent-statistics-never-triggers/"  rel="nofollow">https://mysql.wisborg.dk/2021/08/22/automatic-update-of-innodb-persistent-statistics-never-triggers/</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Wed, 08 Sep 2021 15:52:00 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,698317,698317#msg-698317</guid>
            <title>MySQL:  EXPLAINing the Different EXPLAINS (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,698317,698317#msg-698317</link>
            <description><![CDATA[ <a href="https://elephantdolphin.blogspot.com/2021/08/explaining-different-explains-in-mysql.html"  rel="nofollow">https://elephantdolphin.blogspot.com/2021/08/explaining-different-explains-in-mysql.html</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Thu, 19 Aug 2021 20:57:41 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,697777,697777#msg-697777</guid>
            <title>Multi-valued index is not in possible keys when there is a subquery (1 reply)</title>
            <link>https://forums.mysql.com/read.php?115,697777,697777#msg-697777</link>
            <description><![CDATA[ If we table contains some column based index and also some multi-valued index for a json column, then the query optimizer behaves differently depending on if subquery is used.<br />
<br />
Specifically when a subquery is used then the multi-valued index is NOT listed as a possible keys in the output of the explain command. However, if we change the query not to use any subquery, then the multi-valued index is among the possible keys.<br />
<br />
Does anyone know how to work around this issue?<br />
<br />
I have reported a bug at <a href="https://bugs.mysql.com/bug.php?id=104388"  rel="nofollow">https://bugs.mysql.com/bug.php?id=104388</a>.<br />
<br />
Below is the steps to reproduce the problem.<br />
<br />
mysql&gt; STATUS;<br />
--------------<br />
mysql  Ver 8.0.25 for macos11.3 on x86_64 (Homebrew)<br />
<br />
Connection id:		18<br />
Current database:	myapp<br />
Current user:		root@localhost<br />
SSL:			Not in use<br />
Current pager:		stdout<br />
Using outfile:		&#039;&#039;<br />
Using delimiter:	;<br />
Server version:		8.0.25 Homebrew<br />
Protocol version:	10<br />
Connection:		Localhost via UNIX socket<br />
Server characterset:	utf8mb4<br />
Db     characterset:	utf8mb4<br />
Client characterset:	utf8mb4<br />
Conn.  characterset:	utf8mb4<br />
UNIX socket:		/tmp/mysql.sock<br />
Binary data as:		Hexadecimal<br />
Uptime:			41 min 5 sec<br />
<br />
Threads: 8  Questions: 958  Slow queries: 0  Opens: 1005  Flush tables: 3  Open tables: 912  Queries per second avg: 0.388<br />
--------------<br />
<br />
mysql&gt; <br />
mysql&gt; DROP TABLE IF EXISTS test_json_index;<br />
Query OK, 0 rows affected (0.01 sec)<br />
<br />
mysql&gt; CREATE TABLE test_json_index<br />
    -&gt; (<br />
    -&gt; id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,<br />
    -&gt; OrgID INT NOT NULL,<br />
    -&gt;     BinID INT NOT NULL,<br />
    -&gt; DataBlob json NOT NULL<br />
    -&gt; );<br />
Query OK, 0 rows affected (0.01 sec)<br />
<br />
mysql&gt; ALTER TABLE test_json_index<br />
    -&gt; ADD INDEX (OrgID),<br />
    -&gt; ADD INDEX (BinID),<br />
    -&gt; ADD INDEX indexA (( CAST(DataBlob-&gt;&#039;$.a&#039; AS UNSIGNED INTEGER ARRAY) )),<br />
    -&gt; ADD INDEX indexB (( CAST(DataBlob-&gt;&#039;$.b&#039; AS UNSIGNED ) ));<br />
Query OK, 0 rows affected (0.01 sec)<br />
Records: 0  Duplicates: 0  Warnings: 0<br />
<br />
mysql&gt; <br />
mysql&gt; INSERT INTO test_json_index (OrgID, BinID, DataBlob)<br />
    -&gt; VALUES(<br />
    -&gt; 1, 1, &quot;{\&quot;a\&quot;:[1, 2, 3], \&quot;b\&quot;: 1}&quot;<br />
    -&gt; );<br />
Query OK, 1 row affected (0.00 sec)<br />
<br />
mysql&gt; INSERT INTO test_json_index (OrgID, BinID, DataBlob)<br />
    -&gt; VALUES(<br />
    -&gt; 2, 2, &quot;{\&quot;a\&quot;:[4, 5, 6], \&quot;b\&quot;: 2}&quot;<br />
    -&gt; );<br />
Query OK, 1 row affected (0.00 sec)<br />
<br />
mysql&gt; <br />
mysql&gt; SHOW INDEX FROM test_json_index;<br />
+-----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------------------------------------------------------------+<br />
| Table           | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression                                                       |<br />
+-----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------------------------------------------------------------+<br />
| test_json_index |          0 | PRIMARY  |            1 | id          | A         |           1 |     NULL |   NULL |      | BTREE      |         |               | YES     | NULL                                                             |<br />
| test_json_index |          1 | OrgID    |            1 | OrgID       | A         |           1 |     NULL |   NULL |      | BTREE      |         |               | YES     | NULL                                                             |<br />
| test_json_index |          1 | BinID    |            1 | BinID       | A         |           1 |     NULL |   NULL |      | BTREE      |         |               | YES     | NULL                                                             |<br />
| test_json_index |          1 | indexA   |            1 | NULL        | A         |           1 |     NULL |   NULL | YES  | BTREE      |         |               | YES     | cast(json_extract(`DataBlob`,_utf8mb4\&#039;$.a\&#039;) as unsigned array) |<br />
| test_json_index |          1 | indexB   |            1 | NULL        | A         |           1 |     NULL |   NULL | YES  | BTREE      |         |               | YES     | cast(json_extract(`DataBlob`,_utf8mb4\&#039;$.b\&#039;) as unsigned)       |<br />
+-----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------------------------------------------------------------+<br />
5 rows in set (0.00 sec)<br />
<br />
mysql&gt; <br />
mysql&gt; -- Filter on OrgID and DataBlob.a with a subquery, why is indexA missing in possible keys?<br />
mysql&gt; EXPLAIN SELECT *<br />
    -&gt; FROM (SELECT * from test_json_index where OrgID = 1) as tmp<br />
    -&gt; WHERE 1 member of(tmp.DataBlob-&gt;&#039;$.a&#039;);<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
| id | select_type | table           | partitions | type | possible_keys | key   | key_len | ref   | rows | filtered | Extra       |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
|  1 | SIMPLE      | test_json_index | NULL       | ref  | OrgID         | OrgID | 4       | const |    1 |   100.00 | Using where |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
1 row in set, 1 warning (0.00 sec)<br />
<br />
mysql&gt; <br />
mysql&gt; -- Filter on OrgID and DataBlob.a without a subquery<br />
mysql&gt; EXPLAIN SELECT *<br />
    -&gt; FROM test_json_index<br />
    -&gt; WHERE 1 member of(DataBlob-&gt;&#039;$.a&#039;) AND OrgID = 1;<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
| id | select_type | table           | partitions | type | possible_keys | key   | key_len | ref   | rows | filtered | Extra       |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
|  1 | SIMPLE      | test_json_index | NULL       | ref  | OrgID,indexA  | OrgID | 4       | const |    1 |   100.00 | Using where |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
1 row in set, 1 warning (0.00 sec)<br />
<br />
mysql&gt; <br />
mysql&gt; -- Filter on OrgID and DataBlob.b with a subquery, why is indexB missing in possible keys?<br />
mysql&gt; EXPLAIN SELECT *<br />
    -&gt; FROM (SELECT * from test_json_index where OrgID = 1) as tmp<br />
    -&gt; WHERE 1 = CAST(DataBlob-&gt;&#039;$.b&#039; AS UNSIGNED);<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
| id | select_type | table           | partitions | type | possible_keys | key   | key_len | ref   | rows | filtered | Extra       |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
|  1 | SIMPLE      | test_json_index | NULL       | ref  | OrgID         | OrgID | 4       | const |    1 |   100.00 | Using where |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
1 row in set, 1 warning (0.00 sec)<br />
<br />
mysql&gt; <br />
mysql&gt; -- Filter on OrgID and DataBlob.b without a subquery<br />
mysql&gt; EXPLAIN SELECT *<br />
    -&gt; FROM test_json_index<br />
    -&gt; WHERE 1 = CAST(DataBlob-&gt;&#039;$.b&#039; AS UNSIGNED) AND OrgID = 1;<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
| id | select_type | table           | partitions | type | possible_keys | key   | key_len | ref   | rows | filtered | Extra       |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
|  1 | SIMPLE      | test_json_index | NULL       | ref  | OrgID,indexB  | OrgID | 4       | const |    1 |    50.00 | Using where |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
1 row in set, 1 warning (0.00 sec)<br />
<br />
mysql&gt; <br />
mysql&gt; -- Filter on OrgID and BinID with a subquery, index on BinID is in possible keys<br />
mysql&gt; EXPLAIN SELECT *<br />
    -&gt; FROM (SELECT * from test_json_index where OrgID = 1) as tmp<br />
    -&gt; WHERE 1 = tmp.BinID;<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
| id | select_type | table           | partitions | type | possible_keys | key   | key_len | ref   | rows | filtered | Extra       |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
|  1 | SIMPLE      | test_json_index | NULL       | ref  | OrgID,BinID   | OrgID | 4       | const |    1 |    50.00 | Using where |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
1 row in set, 1 warning (0.00 sec)<br />
<br />
mysql&gt; <br />
mysql&gt; -- Filter on OrgID and BinID without a subquery<br />
mysql&gt; EXPLAIN SELECT *<br />
    -&gt; FROM test_json_index<br />
    -&gt; WHERE 1 = BinID AND OrgID = 1;<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
| id | select_type | table           | partitions | type | possible_keys | key   | key_len | ref   | rows | filtered | Extra       |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
|  1 | SIMPLE      | test_json_index | NULL       | ref  | OrgID,BinID   | OrgID | 4       | const |    1 |    50.00 | Using where |<br />
+----+-------------+-----------------+------------+------+---------------+-------+---------+-------+------+----------+-------------+<br />
1 row in set, 1 warning (0.00 sec)]]></description>
            <dc:creator>Jinlin Yang</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Mon, 04 Oct 2021 18:55:56 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,697632,697632#msg-697632</guid>
            <title>Disable caching in MYSQL for True performance testings? (1 reply)</title>
            <link>https://forums.mysql.com/read.php?115,697632,697632#msg-697632</link>
            <description><![CDATA[ We are trying to optimize some of the slow sql queries. When we first run the query, it&#039;s about XX secs, but after the first run, it only takes less than 1 sec for running the same query. It&#039;s really hard to compare the results for performance testing or query tunning.<br />
<br />
We have disabled the query cache in RDS parameter groups by setting the query cache type,size and limit to 0. And I have set the innodb buffer pool size to the minimum value and the innodb_old_page_pt to 5. But it&#039;s still acting the same -- after the first run, it will be much faster. Unless we have to restart the server or wait for couple of hours or days, then it will show the XX secs again.<br />
<br />
<br />
<br />
Can anyone please suggest me how can I disable the caching in MySQL so that we can show the improvement on the query tunning? Thank you in advance.]]></description>
            <dc:creator>Sing Lau</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Sun, 11 Jul 2021 23:21:42 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,697095,697095#msg-697095</guid>
            <title>Documentation regarding operator precedence incorrect for LIKE, REGEXP, IN? (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,697095,697095#msg-697095</link>
            <description><![CDATA[ I&#039;m looking at MySQL 5.7,<br />
<a href="https://dev.mysql.com/doc/refman/5.7/en/operator-precedence.html"  rel="nofollow">https://dev.mysql.com/doc/refman/5.7/en/operator-precedence.html</a><br />
<br />
It says the following have the same precedence,<br />
<br />
```<br />
= (comparison), &lt;=&gt;, &gt;=, &gt;, &lt;=, &lt;, &lt;&gt;, !=, IS, LIKE, REGEXP, IN<br />
```<br />
<br />
It also says,<br />
<br />
&gt; For operators that occur at the same precedence level within an expression, evaluation proceeds left to right<br />
<br />
This would suggest that `a = b LIKE c` should be parsed as `(a = b) LIKE c`.<br />
However, it is actually parsed as `a = (b LIKE c)`<br />
<br />
The reason is because of the following,<br />
```<br />
predicate:<br />
    ...<br />
    | bit_expr LIKE simple_expr opt_escape<br />
    ...<br />
    | bit_expr<br />
```<br />
<br />
```<br />
bool_pri:<br />
    ...<br />
    | bool_pri comp_op predicate %prec EQ<br />
    ...<br />
    | predicate<br />
```<br />
<br />
<a href="https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_yacc.yy#L9376"  rel="nofollow">https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_yacc.yy#L9376</a><br />
<br />
<a href="https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_yacc.yy#L9308"  rel="nofollow">https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_yacc.yy#L9308</a><br />
<br />
-----<br />
<br />
In order to parse as `(&#039;a&#039; = &#039;a&#039;) LIKE &#039;0&#039;`, we would need a rule like,<br />
<br />
```<br />
predicate:<br />
    ...<br />
    | bool_pri LIKE simple_expr opt_escape<br />
```<br />
<br />
because `&#039;a&#039; = &#039;a&#039;` is a `bool_pri`.<br />
<br />
However, there is no such rule.]]></description>
            <dc:creator>Justin Ng</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Sat, 12 Jun 2021 19:29:04 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,696892,696892#msg-696892</guid>
            <title>How to optimizate COUNT query with multiple LEFT JOIN (2 replies)</title>
            <link>https://forums.mysql.com/read.php?115,696892,696892#msg-696892</link>
            <description><![CDATA[ I have query that select filters for current category and show how many products in each filter are Atm i have 20k products and 10k filters for test that take around 1sec. to execute that is not to good for me is there anything i can do to optimize this query ?<br />
<br />
I found that in WHERE caluse <br />
<br />
 AND sd.filter_group_id = fd.filter_group_id<br />
 AND p.status = 1<br />
<br />
increase executing time a lot if u move them on the LEFT JOIN like this<br />
<br />
LEFT JOIN oc_product p ON p.product_id = p2c.product_id AND p.status = 1<br />
LEFT JOIN oc_sd_filter sd ON sd.category_id = p2c.category_id AND sd.status = 1 AND sd.filter_group_id = fd.filter_group_id<br />
<br />
Executing time become around 0.0600 but results are not same<br />
<br />
How to handle this problem ?<br />
<br />
<br />
Example of my query with selected filters (pf tables are added dynamically depend of filter groups )<br />
<br />
SELECT SQL_NO_CACHE sd.filter_group_id,<br />
        fgd.name AS group_name,<br />
        pf.filter_id AS filter_id,<br />
        fd.name,<br />
        COUNT(DISTINCT p2c.product_id) AS total<br />
    FROM oc_product_to_category p2c <br />
    LEFT JOIN oc_product_filter pf5 ON pf5.product_id = p2c.product_id <br />
    LEFT JOIN oc_product_filter pf8 ON pf8.product_id = p2c.product_id <br />
    LEFT JOIN oc_product_filter pf10 ON pf10.product_id = p2c.product_id <br />
    LEFT JOIN oc_product_filter pf3 ON pf3.product_id = p2c.product_id <br />
    LEFT JOIN oc_product_filter pf9 ON pf9.product_id = p2c.product_id <br />
    LEFT JOIN oc_product_filter pf6 ON pf6.product_id = p2c.product_id <br />
    LEFT JOIN oc_product p ON p.product_id = p2c.product_id<br />
    LEFT JOIN oc_product_filter pf ON pf.product_id = p2c.product_id<br />
    LEFT JOIN oc_filter f ON pf.filter_id = f.filter_id<br />
    LEFT JOIN oc_filter_description fd ON pf.filter_id = fd.filter_id<br />
    LEFT JOIN oc_filter_group_description fgd<br />
          ON fd.filter_group_id = fgd.filter_group_id<br />
    LEFT JOIN oc_sd_filter sd<br />
          ON sd.category_id = p2c.category_id AND sd.status = 1<br />
     WHERE p2c.category_id = &#039;64&#039; <br />
     AND sd.filter_group_id = fd.filter_group_id <br />
     AND p.status = 1<br />
         AND pf5.filter_id IN (33) <br />
         AND pf8.filter_id IN (47,141,143,144,145) <br />
         AND pf10.filter_id IN (118,120,121,122,123,128,129,130,134,138,157,163) <br />
         AND pf3.filter_id IN (9,11) <br />
         AND pf9.filter_id IN (57,58,59,60,61,94,95) <br />
         AND pf6.filter_id IN (116)<br />
        GROUP BY fd.filter_id, fd.filter_group_id<br />
        ORDER BY sd.sort_order ASC, <br />
        (CASE WHEN fgd.custom_order = 0 THEN f.sort_order END) ASC, <br />
        (CASE WHEN fgd.custom_order = 1 THEN COUNT(p2c.product_id) END) DESC<br />
<br />
<br />
Here are my table structure<br />
<br />
        CREATE TABLE `oc_product` (<br />
      `product_id` int(11) NOT NULL,<br />
      `model` varchar(64) NOT NULL,<br />
      `sku` varchar(64) NOT NULL,<br />
      `upc` varchar(12) NOT NULL,<br />
      `ean` varchar(14) NOT NULL,<br />
      `jan` varchar(13) NOT NULL,<br />
      `isbn` varchar(17) NOT NULL,<br />
      `mpn` varchar(64) NOT NULL,<br />
      `location` varchar(128) NOT NULL,<br />
      `quantity` int(4) NOT NULL DEFAULT 0,<br />
      `manufacturer_id` int(11) NOT NULL,<br />
      `price` decimal(15,4) NOT NULL DEFAULT 0.0000,<br />
      `tax_class_id` int(11) NOT NULL,<br />
      `date_available` date NOT NULL DEFAULT &#039;0000-00-00&#039;,<br />
      `sort_order` int(11) NOT NULL DEFAULT 0,<br />
      `status` tinyint(1) NOT NULL DEFAULT 0,<br />
      `date_added` datetime NOT NULL,<br />
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;<br />
<br />
<br />
    ALTER TABLE `oc_product`<br />
      ADD PRIMARY KEY (`product_id`),<br />
      ADD KEY `model` (`model`),<br />
      ADD KEY `manufacturer_id` (`manufacturer_id`),<br />
      ADD KEY `sort_order` (`sort_order`),<br />
      ADD KEY `status` (`status`) USING BTREE;<br />
<br />
        CREATE TABLE `oc_product_to_category` (<br />
      `product_id` int(11) NOT NULL,<br />
      `category_id` int(11) NOT NULL<br />
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;<br />
<br />
    ALTER TABLE `oc_product_to_category`<br />
      ADD PRIMARY KEY (`product_id`,`category_id`),<br />
      ADD KEY `category_id` (`category_id`);<br />
<br />
        CREATE TABLE `oc_product_filter` (<br />
      `product_id` int(11) NOT NULL,<br />
      `filter_id` int(11) NOT NULL<br />
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;<br />
<br />
    ALTER TABLE `oc_product_filter`<br />
      ADD PRIMARY KEY (`product_id`,`filter_id`);<br />
<br />
<br />
        CREATE TABLE `oc_sd_filter` (<br />
      `id` int(11) NOT NULL,<br />
      `category_id` int(11) NOT NULL,<br />
      `filter_group_id` int(11) NOT NULL,<br />
      `status` int(11) NOT NULL,<br />
      `sort_order` int(11) NOT NULL<br />
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;<br />
<br />
    -<br />
    ALTER TABLE `oc_sd_filter`<br />
      ADD PRIMARY KEY (`id`),<br />
      ADD KEY `filter-category` (`category_id`,`filter_group_id`);<br />
<br />
<br />
<br />
    CREATE TABLE `oc_filter` (<br />
      `filter_id` int(11) NOT NULL,<br />
      `filter_group_id` int(11) NOT NULL,<br />
      `sort_order` int(3) NOT NULL<br />
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;<br />
<br />
    ALTER TABLE `oc_filter`<br />
      ADD PRIMARY KEY (`filter_id`);<br />
<br />
<br />
        CREATE TABLE `oc_filter_description` (<br />
      `filter_id` int(11) NOT NULL,<br />
      `language_id` int(11) NOT NULL,<br />
      `filter_group_id` int(11) NOT NULL,<br />
      `name` varchar(64) NOT NULL<br />
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;<br />
<br />
    ALTER TABLE `oc_filter_description`<br />
      ADD PRIMARY KEY (`filter_id`,`language_id`),<br />
      ADD KEY `filter` (`filter_group_id`);<br />
<br />
<br />
        CREATE TABLE `oc_filter_group_description` (<br />
      `filter_group_id` int(11) NOT NULL,<br />
      `language_id` int(11) NOT NULL,<br />
      `name` varchar(64) NOT NULL,<br />
      `level` int(11) NOT NULL,<br />
      `custom_order` int(11) NOT NULL<br />
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;<br />
<br />
    ALTER TABLE `oc_filter_group_description`<br />
      ADD PRIMARY KEY (`filter_group_id`,`language_id`);<br />
<br />
pf10.filter_id IN (118,120,121,122,123,128,129,130,134,138,157,163)<br />
<br />
pf10 represents filter_group<br />
<br />
IN (118,120.....) represents selected filters for current filter_group<br />
<br />
for each selected filter that is in different filter_group i do LEFT JOIN, then all filters from same group go in same IN()]]></description>
            <dc:creator>Ivan Stoqnov</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Tue, 01 Jun 2021 18:19:05 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,696738,696738#msg-696738</guid>
            <title>Need help with tracing how identifiers are parsed; dot-reserved vs dot-space-reserved (1 reply)</title>
            <link>https://forums.mysql.com/read.php?115,696738,696738#msg-696738</link>
            <description><![CDATA[ The following are subtly different.<br />
<br />
+ `CREATE TABLE s.SELECT (X INT);`<br />
+ `CREATE TABLE s. SELECT (X INT);`<br />
<br />
The first statement will create a table named `SELECT`, under the schema `s`.<br />
<br />
The second statement will get a parse error.<br />
<br />
&gt; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#039;SELECT (X INT)&#039; at line 1<br />
<br />
-----<br />
<br />
The difference is whether a space exists after the identifier separator or not.<br />
<br />
I tried looking into the MySQL source code but could not find where this check is performed and what is raising the error.<br />
<br />
I&#039;ve looked at the `table_ident` rule in `sql_yacc.yy`, and states `MY_LEX_IDENT_SEP, MY_LEX_START, MY_LEX_IDENT` in `sql_lex.cc`. I&#039;ve also looked at `Table_ident` in `sql_lex.h/sql_lex.cc`.<br />
<br />
However, I could not figure it out.<br />
<br />
Could someone point me in the right direction, short of having me compile and debug from source?]]></description>
            <dc:creator>Justin Ng</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Tue, 25 May 2021 12:21:54 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,694376,694376#msg-694376</guid>
            <title>MySQL Invisible Column (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,694376,694376#msg-694376</link>
            <description><![CDATA[ MySQL Invisible Column – introduction<br />
<a href="https://lefred.be/content/mysql-invisible-column-part-i/"  rel="nofollow">https://lefred.be/content/mysql-invisible-column-part-i/</a><br />
<br />
MySQL Invisible Column is important for InnoDB Storage Engine<br />
- <a href="https://lefred.be/content/mysql-invisible-column-part-ii/"  rel="nofollow">https://lefred.be/content/mysql-invisible-column-part-ii/</a><br />
<br />
MySQL Invisible Column is important for InnoDB Cluster<br />
- <a href="https://lefred.be/content/mysql-invisible-column-part-iii/"  rel="nofollow">https://lefred.be/content/mysql-invisible-column-part-iii/</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Fri, 22 Jan 2021 19:48:31 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,694103,694103#msg-694103</guid>
            <title>mySQL 8 - view query not using outer predicate (7 replies)</title>
            <link>https://forums.mysql.com/read.php?115,694103,694103#msg-694103</link>
            <description><![CDATA[ It is my understanding from <a href="https://dev.mysql.com/doc/refman/8.0/en/derived-condition-pushdown-optimization.html"  rel="nofollow">https://dev.mysql.com/doc/refman/8.0/en/derived-condition-pushdown-optimization.html</a> the predicate in an outer query should be used in the view query. Either I&#039;m misreading this or the solution escapes me.<br />
<br />
I&#039;m issuing this query:<br />
<br />
explain select * from order_item_oi_only where line_item_auto_key = 1112121<br />
<br />
and getting:<br />
```<br />
1	PRIMARY	&lt;derived2&gt;		ALL					143159	100.00	<br />
2	DERIVED	i		ALL					143159	100.00	Using temporary; Using filesort<br />
2	DERIVED	o		eq_ref	PRIMARY,PARTNER_ACCOUNT_ID_IDX,ACCOUNT_ID_IDX,USER_ID_IDX,ORDER_ENTRY_TIME_IDX,CUST_REF_NUM_IDX,USER_COMMENT_IDX	PRIMARY	8	wtg_ecomm_dev.i.ORDER_ID	1	100.00	<br />
```<br />
<br />
Query is executing the following view:<br />
<br />
    CREATE  OR REPLACE VIEW `Order_Item_oi_only` AS<br />
<br />
SELECT i.line_item_auto_key, JSON_OBJECT(<br />
       &#039;accountId&#039;, o.ACCOUNT_ID,<br />
&#039;buildDate&#039;, o.ORDER_BILLED,<br />
&#039;billingType&#039;, o.BILLING_TYPE,<br />
&#039;clientInfo&#039;, o.USER_COMMENT,<br />
&#039;customerRefNum&#039;, o.CUST_REF_NUM,<br />
&#039;date&#039;, o.ORDER_ENTRY_TIME,<br />
&#039;deliveryNotificationType&#039;, o.DELIVERY_NOTIFICATION_TYPE,<br />
&#039;fulfillmentEmail&#039;, o.FULFILLMENT_EMAIL,<br />
&#039;id&#039;, o.ORDER_AUTO_KEY,<br />
&#039;merchantAccountTransId&#039;, o.MERCHANT_ACCT_TRANS_ID,<br />
&#039;newDownloadsAvailable&#039;, o.NEW_DOWNLOADS_AVAIL,<br />
&#039;notificationMethod&#039;, o.NOTIFY_METHOD,<br />
&#039;orderComments&#039;, o.ORDER_COMMENTS,<br />
&#039;partnerAccountId&#039;, o.PARTNER_ACCOUNT_ID,<br />
&#039;partnerUserAccountId&#039;, o.PARTNER_USER_ACCOUNT_ID,<br />
&#039;partnerUserId&#039;, o.PARTNER_USERID,<br />
&#039;paymentMethod&#039;, o.PAYMENT_METHOD,<br />
&#039;sourceApp&#039;, o.SOURCE_APP,<br />
&#039;status&#039;, o.ORDER_STATUS,<br />
&#039;totalCost&#039;, o.TOTAL_COST,<br />
&#039;userid&#039;, o.USER_ID,<br />
<br />
        &#039;lineItems&#039;, JSON_ARRAYAGG(<br />
            JSON_OBJECT(<br />
&#039;apn&#039;, i.APN,<br />
&#039;canBeGenerated&#039;, i.CAN_BE_GENERATED,<br />
&#039;completeTime&#039;, i.COMPLETE_TIME,<br />
&#039;confirmAllAddlLotsIn&#039;, i.CONF_ALL_ADDL_LOTS_IN,<br />
&#039;confirmIsCBRSOPA&#039;, i.CONF_IS_CBRS_OPA,<br />
&#039;confirmIsClaimOnParcel&#039;, i.CONF_IS_CLAIM_ON_PARCEL,<br />
&#039;confirmIsLOMC&#039;, i.CONF_IS_LOMC,<br />
&#039;confirmIsSFHA&#039;, i.CONF_IS_SFHA,<br />
&#039;countyFIPS&#039;, i.COUNTY_FIPS,<br />
&#039;customerRefNum&#039;, i.CUST_REF_NUM,<br />
&#039;dateAssigned&#039;, i.ASSIGNED_TIME,<br />
&#039;dateDue&#039;, i.DUE_TIME,<br />
&#039;emitPricingOnReport&#039;, i.EMIT_PRICING_ON_REPORT,<br />
&#039;fundId&#039;, i.FUND_ID,<br />
&#039;fundingType&#039;, i.FUNDING_TYPE,<br />
&#039;generationStatus&#039;, i.GENERATION_STATUS,<br />
&#039;id&#039;, i.LINE_ITEM_AUTO_KEY,<br />
&#039;issueCertificateToAddr&#039;, i.ISSUE_CERT_TO_ADDR,<br />
&#039;issueCertificateToName&#039;, i.ISSUE_CERT_TO,<br />
&#039;legalDescription&#039;, i.LEGAL_DESC,<br />
&#039;muniFIPS&#039;, i.MUNI_FIPS,<br />
&#039;orderId&#039;, i.ORDER_ID,<br />
&#039;owner&#039;, i.OWNER,<br />
&#039;parcelBlock&#039;, i.PARCEL_BLOCK,<br />
&#039;parcelDistrict&#039;, i.PARCEL_DISTRICT,<br />
&#039;parcelKey&#039;, i.PARCEL_KEY,<br />
&#039;parcelLot&#039;, i.PARCEL_LOT,<br />
&#039;parcelQualifier&#039;, i.PARCEL_QUALIFY,<br />
&#039;parsedMisc&#039;, i.PARSED_MISC,<br />
&#039;price&#039;, i.PRICE,<br />
&#039;processStartTime&#039;, i.PROCESS_START_TIME,<br />
&#039;productId&#039;, i.PRODUCT_ID,<br />
&#039;providerId&#039;, i.PROVIDER_ID,<br />
&#039;providerOKToPay&#039;, i.PROVIDER_OK_TO_PAY,<br />
&#039;quantity&#039;, i.QUANTITY,<br />
&#039;stateFIPS&#039;, i.STATE_FIPS,<br />
&#039;status&#039;, i.ITEM_STATUS,<br />
&#039;statusReason&#039;, i.ITEM_STATUS_REASON,<br />
&#039;streetAddress&#039;, i.STREET_ADDR,<br />
&#039;taxSearchIncludeUtils&#039;, i.TAX_SEARCH_INCLUDE_UTILS,<br />
&#039;townId&#039;, i.TOWN_ID,<br />
&#039;userComment&#039;, i.USER_COMMENT,<br />
&#039;workerId&#039;, i.WORKER_ID<br />
            )<br />
        )<br />
    ) as order_json<br />
    FROM LINE_ITEMS i  FORCE INDEX (PRIMARY)<br />
    LEFT JOIN ORDERS o ON o.order_auto_key = i.order_id<br />
    group by o.order_auto_key<br />
where both the following are primary keys on their respective tables:<br />
<br />
o.order_auto_key i.line_item_auto_key<br />
<br />
I&#039;m running mySQL 8.0.22<br />
<br />
Could sure use some help with this one. Thanks.]]></description>
            <dc:creator>Jack Crawford</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Tue, 12 Jan 2021 04:34:02 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,689672,689672#msg-689672</guid>
            <title>MySQL Comparing INTs and CHARs (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,689672,689672#msg-689672</link>
            <description><![CDATA[ <a href="https://elephantdolphin.blogspot.com/2020/08/mysql-comparing-ints-and-chars.html"  rel="nofollow">https://elephantdolphin.blogspot.com/2020/08/mysql-comparing-ints-and-chars.html</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Mon, 24 Aug 2020 20:56:34 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,689256,689256#msg-689256</guid>
            <title>MySQL 8.0 Indexes, Histograms, and Other Ways to Speed Up Your Queries (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,689256,689256#msg-689256</link>
            <description><![CDATA[ MySQL 8.0 Indexes, Histograms, and Other Ways to Speed Up Your Queries<br />
-  <a href="https://www.slideshare.net/davestokes/mysql-80-indexes-histograms-and-other-ways-to-speed-up-your-queries"  rel="nofollow">https://www.slideshare.net/davestokes/mysql-80-indexes-histograms-and-other-ways-to-speed-up-your-queries</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Wed, 05 Aug 2020 01:57:45 +0000</pubDate>
        </item>
        <item>
            <guid>https://forums.mysql.com/read.php?115,689220,689220#msg-689220</guid>
            <title>MySQL:  Using SKIP LOCK For Queue Processing (no replies)</title>
            <link>https://forums.mysql.com/read.php?115,689220,689220#msg-689220</link>
            <description><![CDATA[ SKIP LOCKED and NOWAIT:<br />
- <a href="http://mysqlserverteam.com/mysql-8-0-1-using-skip-locked-and-nowait-to-handle-hot-rows/"  rel="nofollow">http://mysqlserverteam.com/mysql-8-0-1-using-skip-locked-and-nowait-to-handle-hot-rows/</a><br />
- <a href="https://www.percona.com/blog/2020/08/03/using-skip-lock-for-queue-processing-in-mysql/"  rel="nofollow">https://www.percona.com/blog/2020/08/03/using-skip-lock-for-queue-processing-in-mysql/</a>]]></description>
            <dc:creator>Edwin Desouza</dc:creator>
            <category>Optimizer &amp; Parser</category>
            <pubDate>Mon, 03 Aug 2020 16:00:27 +0000</pubDate>
        </item>
    </channel>
</rss>
