Comments on: Using Prometheus to Check for auto_increment Value Exhaustion https://www.percona.com/blog/using-prometheus-to-check-for-auto_increment-value-exhaustion/ Tue, 06 Aug 2019 19:57:13 +0000 hourly 1 https://wordpress.org/?v=6.5.2 By: ChenGuangjing(Andy) https://www.percona.com/blog/using-prometheus-to-check-for-auto_increment-value-exhaustion/#comment-10968868 Wed, 10 Jan 2018 03:10:39 +0000 https://www.percona.com/blog/?p=45913#comment-10968868 I also have a query to get the result

SELECT table_schema, table_name, column_name, column_type, auto_increment,max_int,ROUND(auto_increment/max_int*100,2) AS “USED %” FROM
(SELECT table_schema, table_name, column_name, column_type, auto_increment,
pow(2, case data_type
when ‘tinyint’ then 7
when ‘smallint’ then 15
when ‘mediumint’ then 23
when ‘int’ then 31
when ‘bigint’ then 63
end+(column_type like ‘% unsigned’))-1 as max_int
FROM information_schema.tables t
JOIN information_schema.columns c USING (table_schema,table_name)
WHERE t.table_schema not in (‘mysql’,’information_schema’,’performance_schema’) and t.table_type = ‘base table’
and c.extra = ‘auto_increment’ AND t.auto_increment IS NOT NULL order by auto_increment desc limit 10) TMP;
Here is my test result

+————–+————+————-+——————+—————-+————+——–+
| table_schema | table_name | column_name | column_type | auto_increment | max_int | USED % |
+————–+————+————-+——————+—————-+————+——–+
| edxapp | andy | id | int(10) unsigned | 4294967295 | 4294967295 | 100.00 |
| examlogin | andy | id | int(11) | 2147483641 | 2147483647 | 100.00 |
+————–+————+————-+——————+—————-+————+——–+
2 rows in set (0.11 sec)

]]>
By: Vinoth Kanna https://www.percona.com/blog/using-prometheus-to-check-for-auto_increment-value-exhaustion/#comment-10968677 Thu, 16 Nov 2017 14:16:21 +0000 https://www.percona.com/blog/?p=45913#comment-10968677 * where usg >= USER_INPUT limit 10;

I marked the text “USER_INPUT” between , It disappeared

]]>
By: Vinoth Kanna https://www.percona.com/blog/using-prometheus-to-check-for-auto_increment-value-exhaustion/#comment-10968676 Thu, 16 Nov 2017 14:13:45 +0000 https://www.percona.com/blog/?p=45913#comment-10968676 Indeed, It’s very much helpful, But I still tend to use the tweaked version of common_schema query to quickly check through the server where we don’t have PMM.

select tab as ‘Table’, col as ‘Column’, cv as ‘Current Value’, ud as ‘Appox. Usage Period (Days)’, round(usg,2) as ‘Usage %’ from (select concat(table_schema,’.’,table_name) as tab, concat(column_name,’ ‘,column_type,’ ‘,if(locate(‘unsigned’, column_type)=0,’signed’,”)) as col, auto_increment as cv, datediff(now(),create_time) as ud, ((auto_increment/(case data_type when ‘tinyint’ then 255 when ‘smallint’ then 65535 when ‘mediumint’ then 16777215 when ‘int’ then 4294967295 when ‘bigint’ then 18446744073709551615 end >> if(locate(‘unsigned’, column_type)>0,0,1)))*100) as usg from information_schema.columns inner join information_schema.tables using (table_schema, table_name) where table_schema not in (‘mysql’,’information_schema’,’performance_schema’) and table_type = ‘base table’ and extra = ‘auto_increment’ order by 5 desc, 3 desc) as get_auto_inc_usage where usg >= limit 10;

USER_INPUT -> In % (Auto Increment Usage)


Sample Output:
+---------------------------------+-------------------------------+---------------+----------------------------+---------+
| Table | Column | Current Value | Appox. Usage Period (Days) | Usage % |
+---------------------------------+-------------------------------+---------------+----------------------------+---------+
| test.tickets | id tinyint(4) signed | 100 | 0 | 78.74 |
| helpdesk.hd_ticket_priority | priority_id tinyint(4) signed | 5 | 406 | 3.94 |
| helpdesk.hd_syslog | log_id int(11) unsigned | 439118 | 198 | 0.01 |

]]>
By: Wagner Bianchi https://www.percona.com/blog/using-prometheus-to-check-for-auto_increment-value-exhaustion/#comment-10968654 Fri, 10 Nov 2017 13:59:22 +0000 https://www.percona.com/blog/?p=45913#comment-10968654 Awesomesauce!

]]>