Comment 1 for bug 716879

Revision history for this message
shinguz (oli-sennhauser) wrote :

Related to this bug I was dreaming: We live in a relational world. So everything should be a table...

Instead of writing those information to the error log (which does not even happen because of the bug) I would like to have written them in a table.

CHECK TABLE imho is anway the wrong command. I would prefer the ANALZYE TABLE command instead (but this is a detail).

So what I would like to have is:

ANALYZE TABLE foodmart.product;

and then:

SELECT * from pbxt.table_statistics;
+---------------+--------------+------------+--------------------+----------------------------+-------------------------+-----------------+-----------------+-----------------+-----------------+-----------------+----------------+-------------------+----------------+-------------------+--------------------+-------------------+-------------------------+----------------------------+----------------------------------+----------------------------+------------------------+-------------------+----------------------+-----------------------+---------------------------+---------------------------+---------------------------+-------------------+----------------------+------------------------+
| Table_catalog | Table_schema | Table_name | Record_buffer_size | Fixed_length_record_length | Handle_data_record_size | Min_header_size | Max_header_size | Min_record_size | Avg_record_size | Max_record_size | Avg_row_length | Rows_fixed_length | Max_fixed size | Min_variable size | Min_auto_increment | Number_of_columns | Number_of_fixed_columns | Columns_required_for_index | Record_length_required_for_index | Columns_required_for_blobs | Number_of_blob_columns | Number_of_indices | Extended_data_length | Extended_record_count | Min_compare_record_length | Avg_compare_record_length | Max_compare_record_length | Free_record_count | Deleted_record_count | Allocated_record_count |
+---------------+--------------+------------+--------------------+----------------------------+-------------------------+-----------------+-----------------+-----------------+-----------------+-----------------+----------------+-------------------+----------------+-------------------+--------------------+-------------------+-------------------------+----------------------------+----------------------------------+----------------------------+------------------------+-------------------+----------------------+-----------------------+---------------------------+---------------------------+---------------------------+-------------------+----------------------+------------------------+
| NULL | foodmart | product | 192 | 191 | 205 | 14 | 14 | 82 | 202 | 202 | NULL | YES | 16384 | 320 | 0 | 15 | 0 | 5 | 140 | 0 | 0 | 5 | NULL | NULL | 93 | 112 | 138 | 0 | 0 | 1560 |
| NULL | foodmart | product2 | 192 | 191 | 74 | 14 | 26 | 82 | 202 | 202 | 60 | NO | 65536 | 320 | 0 | 15 | 8 | 15 | 202 | 0 | 0 | 5 | 65008 | 1560 | 86 | 90 | 90 | 0 | 0 | 1560 |
+---------------+--------------+------------+--------------------+----------------------------+-------------------------+-----------------+-----------------+-----------------+-----------------+-----------------+----------------+-------------------+----------------+-------------------+--------------------+-------------------+-------------------------+----------------------------+----------------------------------+----------------------------+------------------------+-------------------+----------------------+-----------------------+---------------------------+---------------------------+---------------------------+-------------------+----------------------+------------------------+

CREATE TEMPORARY TABLE pbxt.table_statistics (
  `Table_catalog` varchar(512) DEFAULT NULL,
  `Table_schema` varchar(64) NOT NULL DEFAULT '',
  `Table_name` varchar(64) NOT NULL DEFAULT '',
  `Record_buffer_size` int unsigned NOT NULL DEFAULT 0,
  `Fixed_length_record_length` int unsigned NOT NULL DEFAULT 0, # why length and not size?
  `Handle_data_record_size` int unsigned NOT NULL DEFAULT 0,
  `Min_header_size` int unsigned NOT NULL DEFAULT 0,
  `Max_header_size` int unsigned NOT NULL DEFAULT 0,
  `Min_record_size` bigint unsigned NOT NULL DEFAULT 0,
  `Avg_record_size` bigint unsigned NOT NULL DEFAULT 0,
  `Max_record_size` bigint unsigned NOT NULL DEFAULT 0,
  `Avg_row_length` int unsigned NULL DEFAULT NULL,
  `Rows_fixed_length` char(3) NOT NULL DEFAULT 'YES',
  `Max_fixed size` int unsigned NOT NULL DEFAULT 0,
  `Min_variable size` int unsigned NOT NULL DEFAULT 0,
  `Min_auto_increment` bigint unsigned NOT NULL DEFAULT 0,
  `Number_of_columns` int unsigned NOT NULL DEFAULT 0,
  `Number_of_fixed_columns` int unsigned NOT NULL DEFAULT 0,
  `Columns_required_for_index` int unsigned NOT NULL DEFAULT 0,
  `Record_length_required_for_index` bigint unsigned NOT NULL DEFAULT 0,
  `Columns_required_for_blobs` int unsigned NOT NULL DEFAULT 0,
  `Number_of_blob_columns` int unsigned NOT NULL DEFAULT 0,
  `Number_of_indices` int unsigned NOT NULL DEFAULT 0,
  `Extended_data_length` bigint unsigned NULL DEFAULT NULL,
  `Extended_record_count` bigint unsigned NULL DEFAULT NULL,
  `Min_compare_record_length` bigint unsigned NOT NULL DEFAULT 0,
  `Avg_compare_record_length` bigint unsigned NOT NULL DEFAULT 0,
  `Max_compare_record_length` bigint unsigned NOT NULL DEFAULT 0,
  `Free_record_count` bigint unsigned NOT NULL DEFAULT 0,
  `Deleted_record_count` bigint unsigned NOT NULL DEFAULT 0,
  `Allocated_record_count` bigint unsigned NOT NULL DEFAULT 0
) ENGINE=PBXT DEFAULT CHARSET=utf8

insert into pbxt.table_statistics values
( NULL, 'foodmart', 'product', 192, 191, 205, 14, 14, 82, 202, 202, NULL, 'YES', 16384, 320, 0, 15, 0, 5, 140, 0, 0, 5, null, null, 93, 112, 138, 0, 0, 1560)
, ( NULL, 'foodmart', 'product2', 192, 191, 74, 14, 26, 82, 202, 202, 60, 'NO', 65536, 320, 0, 15, 8, 15, 202, 0, 0, 5, 65008, 1560, 86, 90, 90, 0, 0, 1560)
;

This is a much better way imho when you want to do some reports and automatized analytics about your tables for performance tuning etc.