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

Userstat Key_read_hits/Key_read_misses do not work for descending keys

    XMLWordPrintable

Details

    Description

      Note: I'm setting it to Major rather than Critical even though it's an issue in a new feature (MDEV-33151), because as described in the comment to MDEV-33151 and in MDEV-33916 (closed as "won't fix"), semantics of Key_read_hits/Key_read_misses is incomprehensible anyway, so while it can be reasonably assumed that the behavior described here is wrong, it's hard to specify what would be the expected result.

      set @userstat.save= @@userstat;
      set global userstat= 1;
       
      create table t (a int, key(a desc));
      insert into t values (1),(2),(3),(4),(5),(6);
       
      flush user_statistics, table_statistics;
       
      explain select * from t where a > 3;
      select * from t where a > 3;
       
      select key_read_hits, key_read_misses from information_schema.user_statistics where user = 'root';
      select key_read_hits, key_read_misses from information_schema.table_statistics where table_schema = 'test';
       
      explain select * from t where a > 10;
      select * from t where a > 10;
       
      select key_read_hits, key_read_misses from information_schema.user_statistics where user = 'root';
      select key_read_hits, key_read_misses from information_schema.table_statistics where table_schema = 'test';
       
      # Cleanup
      set global userstat= @userstat.save;
      drop table t;
      

      bb-11.5-MDEV-33151-userstat 8f786ad4671368fa5e92c82cb47fb124ff06c14c

      explain select * from t where a > 3;
      id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
      1	SIMPLE	t	range	a	a	5	NULL	3	Using where; Using index
      select * from t where a > 3;
      a
      6
      5
      4
      select key_read_hits, key_read_misses from information_schema.user_statistics where user = 'root';
      key_read_hits	key_read_misses
      0	0
      select key_read_hits, key_read_misses from information_schema.table_statistics where table_schema = 'test';
      key_read_hits	key_read_misses
      0	0
      

      explain select * from t where a > 10;
      id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
      1	SIMPLE	t	range	a	a	5	NULL	1	Using where; Using index
      select * from t where a > 10;
      a
      select key_read_hits, key_read_misses from information_schema.user_statistics where user = 'root';
      key_read_hits	key_read_misses
      0	0
      select key_read_hits, key_read_misses from information_schema.table_statistics where table_schema = 'test';
      key_read_hits	key_read_misses
      0	0
      

      So, neither hits nor misses are detected. With an ASC instead of a DESC key and otherwise the same test case, the values are incremented.

      Attachments

        Issue Links

          Activity

            People

              monty Michael Widenius
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.