Guest User

Untitled

a guest
Jul 16th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.78 KB | None | 0 0
  1. SELECT Concat(t.table_schema, '.', t.table_name),
  2. t.table_rows,
  3. snu.non_unique,
  4. smax.cardinality,
  5. ( t.table_rows / Ifnull(smax.cardinality, 1) ) AS
  6. "medium distribution",
  7. t.table_rows * ( t.table_rows / Ifnull(smax.cardinality, 1) ) AS
  8. "replication row reads"
  9. FROM information_schema.tables t
  10. LEFT JOIN (SELECT table_schema,
  11. table_name,
  12. Max(cardinality) cardinality
  13. FROM information_schema.statistics
  14. GROUP BY table_schema,
  15. table_name) AS smax
  16. ON t.table_schema = smax.table_schema
  17. AND t.table_name = smax.table_name
  18. LEFT JOIN (SELECT table_schema,
  19. table_name,
  20. Min(non_unique) non_unique
  21. FROM information_schema.statistics
  22. GROUP BY table_schema,
  23. table_name) AS snu
  24. ON t.table_schema = snu.table_schema
  25. AND t.table_name = snu.table_name
  26. WHERE t.table_rows > 0
  27. AND t.table_schema <> 'information_schema'
  28. AND t.table_schema <> 'performance_schema'
  29. AND t.table_schema <> 'mysql'
  30. AND ( snu.non_unique IS NULL
  31. OR snu.non_unique = 1 )
  32. AND ( ( t.table_rows / Ifnull(smax.cardinality, 1) ) > 1.99 )
  33. AND t.table_rows * ( t.table_rows / Ifnull(smax.cardinality, 1) ) >
  34. 100000
  35. ORDER BY t.table_rows * ( t.table_rows / Ifnull(smax.cardinality, 1) ) DESC;
  36.  
  37. (none)> show variables like '%version%';
  38. +-------------------------+---------------------------+
  39. | Variable_name | Value |
  40. +-------------------------+---------------------------+
  41. | innodb_version | 5.6.36-82.1 |
  42. | protocol_version | 10 |
  43. | slave_type_conversions | |
  44. | version | 10.1.26-MariaDB |
  45. | version_comment | Source distribution |
  46. | version_compile_machine | x86_64 |
  47. | version_compile_os | Linux |
  48. | version_malloc_library | system |
  49. | version_ssl_library | OpenSSL 1.0.1f 6 Jan 2014 |
  50. | wsrep_patch_version | wsrep_25.19 |
  51. +-------------------------+---------------------------+
  52. 10 rows in set
  53. Time: 0.010s
  54.  
  55. +----+-------------+------------+------+---------------+--------+---------+-------------------------------------------------------------------+--------+----------+--------------------------------------------------------------------------------------+
  56. | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
  57. +----+-------------+------------+------+---------------+--------+---------+-------------------------------------------------------------------+--------+----------+--------------------------------------------------------------------------------------+
  58. | 1 | PRIMARY | t | ALL | <null> | <null> | <null> | <null> | <null> | <null> | Using where; Open_full_table; Scanned all databases; Using temporary; Using filesort |
  59. | 1 | PRIMARY | <derived2> | ref | key0 | key0 | 390 | information_schema.t.TABLE_SCHEMA,information_schema.t.TABLE_NAME | 2 | 100.0 | Using where |
  60. | 1 | PRIMARY | <derived3> | ref | key0 | key0 | 390 | information_schema.t.TABLE_SCHEMA,information_schema.t.TABLE_NAME | 2 | 100.0 | Using where |
  61. | 3 | DERIVED | statistics | ALL | <null> | <null> | <null> | <null> | <null> | <null> | Open_frm_only; Scanned all databases; Using temporary; Using filesort |
  62. | 2 | DERIVED | statistics | ALL | <null> | <null> | <null> | <null> | <null> | <null> | Open_full_table; Scanned all databases; Using temporary; Using filesort |
  63. +----+-------------+------------+------+---------------+--------+---------+-------------------------------------------------------------------+--------+----------+--------------------------------------------------------------------------------------+
  64. 5 rows in set
  65. Time: 0.022s
  66.  
  67. > select count('A') from information_schema.tables;
  68. +------------+
  69. | count('A') |
  70. +------------+
  71. | 7846 |
  72. +------------+
  73. 1 row in set
  74. Time: 0.069s
Add Comment
Please, Sign In to add comment