Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-33904

For triggers INDEX_STATISTICS.QUERIES only counts the triggering query

    XMLWordPrintable

Details

    Description

      Unlike for procedure calls, where INDEX_STATISTICS.QUERIES counts relevant queries within the procedure, if the queries are executed within a trigger, it only counts the query which caused the trigger execution, regardless how many times the triggers were executed and how many queries were within.
      Maybe it is intentional, but it's not clear from MDEV-33152 where the counter was added. If it's intentional, please convert it into a documentation request.
      See also MDEV-33903 – same for stored functions.

      SET @userstat.save= @@userstat;
      set global userstat= 1;
       
      create or replace table t1 (a int, key(a));
      insert into t1 values (1),(2),(3),(4),(1);
      create or replace table t2 (b int);
      create trigger tr before insert on t2 for each row set new.b = (select count(*) from t1 where a = new.b);
      flush index_statistics;
      insert into t2 values (1),(2),(3),(4),(5);
      show index_statistics;
       
      # Cleanup
      set global userstat= @userstat.save;
      drop table t1, t2;
      

      bb-11.5-MDEV-33152-index-statistics 802e89b176efd8ef995cdd456a04ac6452f0e284

      flush index_statistics;
      insert into t2 values (1),(2),(3),(4),(5);
      show index_statistics;
      Table_schema	Table_name	Index_name	Rows_read	Queries
      test	t1	a	5	1
      

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.