Userstats to capture how many bytes of an index has been used

Bug #483249 reported by Ryan Lowe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Server moved to https://jira.percona.com/projects/PS
Won't Fix
Wishlist
Oleg Tsarev
Percona patches
Won't Fix
Wishlist
Unassigned

Bug Description

Say I have the following table:

CREATE TABLE `t1` (
  `id` int unsigned NOT NULL auto_increment PRIMARY KEY,
  `c1` int,
  `c2` int,
  `c3` int,
  INDEX `idx1` (`c3`,`c2`,`c1`)
  );

And I issue the following query:

SELECT `id` FROM `t1` WHERE `c3`=6;

This will show that the index has been used, but what I want to know is how many bytes were used. This way I can not only drop unused indexes, but also shorten indexes that include too many columns.

Tags: userstats
Changed in percona-patches:
status: New → Confirmed
importance: Undecided → High
assignee: nobody → Yasufumi Kinoshita (yasufumi-kinoshita)
Changed in percona-patches:
milestone: none → 5.1.43
Revision history for this message
Yasufumi Kinoshita (yasufumi-kinoshita) wrote :

Sorry, I don't catch up with your intention of "how many bytes were used" of index....

Do you want each read/write access to the index pages in buffer pool?

e.g.)
root page: scan page_no to find page_no of the leaf pages 8+8+8+...
branch page: scan page_no to find page_no of the next pages 8+8+8+...
....
leaf page: scan rec and read it 8+8+....40

I don't want such slower and big patch to InnoDB/MyISAM.....
And I don't think "how many bytes were used" are useful...

Revision history for this message
Ryan Lowe (ryan-a-lowe) wrote :

Hey Yasufumi,

Say I have:

mysql> SHOW CREATE TABLE t1\G
*************************** 1. row ***************************
       Table: t1
Create Table: CREATE TABLE `t1` (
  `c1` int(11) default NULL,
  `c2` int(11) default NULL,
  `c3` int(11) default NULL,
  `c4` int(11) default NULL,
  `c5` int(11) default NULL,
  KEY `c1` (`c1`,`c2`),
  KEY `c2` (`c2`,`c3`,`c4`,`c5`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

mysql> EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1=1234\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: t1
         type: ref
possible_keys: c1
          key: c1
      key_len: 5
          ref: const
         rows: 1
        Extra: Using where; Using index
1 row in set (0.00 sec)

mysql> EXPLAIN SELECT COUNT(*) FROM t1 WHERE c1=1234 AND c2=12345\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: t1
         type: ref
possible_keys: c1,c2
          key: c1
      key_len: 10
          ref: const,const
         rows: 1
        Extra: Using where; Using index
1 row in set (0.00 sec)

Note the key_len goes from 5 to 10. What happens is that I often see customers who have indexes on (c1,c2,c3,c4,...,c15) but when I do a query analysis, I only see queries with WHERE c1=x and c2=y. They know they added the index in the past for a reason, but can't remember why. I guess one option is for me to find all queries that access the table and then manually EXPLAIN them to see how much of the index they use, but that seems like a lot of work.

There's no way of tracking this without significant performance impact?

Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

This is not easy to implement, I moved it to "Wishlist"

Changed in percona-patches:
importance: High → Wishlist
milestone: 5.1.43 → none
Revision history for this message
Stewart Smith (stewart) wrote :

Moved to Percona Server

Changed in percona-server:
status: New → Triaged
importance: Undecided → Wishlist
Changed in percona-patches:
status: Confirmed → Won't Fix
Oleg Tsarev (tsarev)
tags: added: userstats
Oleg Tsarev (tsarev)
Changed in percona-server:
status: Triaged → Won't Fix
assignee: nobody → Oleg Tsarev (tsarev)
Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-2295

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.