scripts/collector/mysql/sql/database_details.sql [101:178]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
          COALESCE(pt.PARTITION_COUNT, 0) as partition_count,
          COALESCE(idx.index_count, 0) as index_count,
          COALESCE(idx.fulltext_index_count, 0) as fulltext_index_count,
          COALESCE(idx.spatial_index_count, 0) as spatial_index_count
        from information_schema.TABLES t
          left join (
            select TABLE_SCHEMA,
              TABLE_NAME,
              PARTITION_METHOD,
              SUBPARTITION_METHOD,
              count(1) as PARTITION_COUNT
            from information_schema.PARTITIONS
            where table_schema not in (
                'mysql',
                'information_schema',
                'performance_schema',
                'sys'
              )
            group by TABLE_SCHEMA,
              TABLE_NAME,
              PARTITION_METHOD,
              SUBPARTITION_METHOD
          ) pt on (
            t.table_schema = pt.table_schema
            and t.TABLE_NAME = pt.TABLE_NAME
          )
          left join (
            select table_schema,
              TABLE_NAME
            from information_schema.statistics
            where table_schema not in (
                'mysql',
                'information_schema',
                'performance_schema',
                'sys'
              )
            group by table_schema,
              TABLE_NAME,
              index_name
            having SUM(
                if(
                  non_unique = 0
                  and NULLABLE != 'YES',
                  1,
                  0
                )
              ) = count(*)
          ) pks on (
            t.table_schema = pks.table_schema
            and t.TABLE_NAME = pks.TABLE_NAME
          )
          left join (
            select s.table_schema,
              s.table_name,
              count(1) as index_count,
              sum(
                if(s.INDEX_TYPE = 'FULLTEXT', 1, 0)
              ) as fulltext_index_count,
              sum(if(s.INDEX_TYPE = 'SPATIAL', 1, 0)) as spatial_index_count
            from information_schema.STATISTICS s
            where s.table_schema not in (
                'mysql',
                'information_schema',
                'performance_schema',
                'sys'
              )
            group by s.table_schema,
              s.table_name
          ) idx on (
            t.table_schema = idx.table_schema
            and t.TABLE_NAME = idx.TABLE_NAME
          )
        where t.table_schema not in (
            'mysql',
            'information_schema',
            'performance_schema',
            'sys'
          )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/dma/collector/sql/sources/mysql/collection-table_details.sql [56:133]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      COALESCE(pt.PARTITION_COUNT, 0) as partition_count,
      COALESCE(idx.index_count, 0) as index_count,
      COALESCE(idx.fulltext_index_count, 0) as fulltext_index_count,
      COALESCE(idx.spatial_index_count, 0) as spatial_index_count
    from information_schema.TABLES t
      left join (
        select TABLE_SCHEMA,
          TABLE_NAME,
          PARTITION_METHOD,
          SUBPARTITION_METHOD,
          count(1) as PARTITION_COUNT
        from information_schema.PARTITIONS
        where table_schema not in (
            'mysql',
            'information_schema',
            'performance_schema',
            'sys'
          )
        group by TABLE_SCHEMA,
          TABLE_NAME,
          PARTITION_METHOD,
          SUBPARTITION_METHOD
      ) pt on (
        t.table_schema = pt.table_schema
        and t.TABLE_NAME = pt.TABLE_NAME
      )
      left join (
        select table_schema,
          TABLE_NAME
        from information_schema.statistics
        where table_schema not in (
            'mysql',
            'information_schema',
            'performance_schema',
            'sys'
          )
        group by table_schema,
          TABLE_NAME,
          index_name
        having SUM(
            if(
              non_unique = 0
              and NULLABLE != 'YES',
              1,
              0
            )
          ) = count(*)
      ) pks on (
        t.table_schema = pks.table_schema
        and t.TABLE_NAME = pks.TABLE_NAME
      )
      left join (
        select s.table_schema,
          s.table_name,
          count(1) as index_count,
          sum(
            if(s.INDEX_TYPE = 'FULLTEXT', 1, 0)
          ) as fulltext_index_count,
          sum(if(s.INDEX_TYPE = 'SPATIAL', 1, 0)) as spatial_index_count
        from information_schema.STATISTICS s
        where s.table_schema not in (
            'mysql',
            'information_schema',
            'performance_schema',
            'sys'
          )
        group by s.table_schema,
          s.table_name
      ) idx on (
        t.table_schema = idx.table_schema
        and t.TABLE_NAME = idx.TABLE_NAME
      )
    where t.table_schema not in (
        'mysql',
        'information_schema',
        'performance_schema',
        'sys'
      )
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



