I have a strange problem with a particular database:
mysql> update person set last_name=null where first_name='john';
ERROR 1713 (HY000): Undo log record is too big.
What can be the problem?
(I've already googled quite a log)
mysql 5.7.20 installed with brew on Mac OSX 10.12.6.
show table status where name = 'person'
-> ;
+--------------------+--------+---------+------------+--------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+--------------------+--------+---------+------------+--------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+
| person | InnoDB | 10 | Dynamic | 650918 | 4322 | 2813853696 | 0 | 1369833472 | 6291456 | NULL | 2017-09-12 14:31:20 | 2017-10-24 12:37:03 | NULL | utf8mb4_unicode_ci | NULL | | |
+--------------------+--------+---------+------------+--------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+
1 row in set (0.00 sec)
Related
I'm trying to add an index to an existing table as part of the upgrade process for Invision Community forums. The database is hosted in AWS Aurora Serverless, which has MySQL 5.6 compatibility. However, every time, I receive the error:
ERROR 1709 (HY000): Index column size too large. The maximum column size is 767 bytes.
Here are the details about the table and the schema:
+---------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+--------------------+----------+--------------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+---------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+--------------------+----------+--------------------+---------+
| ibf_core_tags | InnoDB | 10 | Dynamic | 36862 | 299 | 11026432 | 0 | 13189120 | 4194304 | 95183 | NULL | NULL | NULL | utf8mb4_unicode_ci | NULL | row_format=DYNAMIC | |
+---------------+--------+---------+------------+-------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+--------------------+----------+--------------------+---------+
+--------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+----------------+
| tag_id | bigint(20) | NO | PRI | NULL | auto_increment |
| tag_aai_lookup | char(32) | NO | MUL | | |
| tag_aap_lookup | char(32) | NO | MUL | | |
| tag_meta_app | varchar(200) | NO | MUL | | |
| tag_meta_area | varchar(200) | NO | | | |
| tag_meta_id | int(10) | NO | | 0 | |
| tag_meta_parent_id | int(10) | NO | | 0 | |
| tag_member_id | int(10) | NO | MUL | 0 | |
| tag_added | int(10) | NO | MUL | 0 | |
| tag_prefix | int(1) | NO | | 0 | |
| tag_text | varchar(255) | YES | | NULL | |
+--------------------+--------------+------+-----+---------+----------------+
Default charset for the table is utf8mb4 and the innodb_large_prefix setting is ON.
The operation I'm trying to do is:
ALTER TABLE `ibf_core_tags` ADD KEY `tag_text` (`tag_text`(191));
I would think 191 * 4 = 764, which is less than the 767 byte value it says I'm exceeding. Is this a bug in Aurora Serverless? Is there a way around this issue? I've tried changing the table to MyISAM to add the index, but I actually get the same error when I try that.
Using a local install of MySQL 5.6, I was able to run this ALTER TABLE query on the same database, so I'm not sure why Aurora Serverless is any different.
I ended up trying this on a non-serverless Aurora instance and had that same issue.
I had this same issue with a Slim PHP project using Laravel for the DB connections. By default, AWS Aurora Serverless is using the file format of Antelope which defaults to the row format of COMPACT. We need a file format of Barracuda and a row format of DYNAMIC in order to allow large index key prefixes (reference).
I created a custom Parameter Group and explicitly set the following parameters:
innodb_file_format = Barracuda
innodb_file_per_table = 1
innodb_large_prefix = 1
These params are allowed to be set according to AWS's Aurora Serverless documentation.
Setting these params didn't fix the issue by itself though. Tables were still being created with a row format of COMPACT. In the DB connection params I also had to set 'engine' => 'InnoDB ROW_FORMAT=DYNAMIC' (reference). This syntax is for Laravel but hopefully it points others in the right direction as I just spent a whole afternoon figuring it out :)
I have table ip_per_nat_vlan, innodb format. When I give truncate table, table is empty.
Then I have php script, which fill data into this table.
When is this script finished without errors (simple insert statemets) situation is following:
select * from ip_per_nat_vlan;
Empty set (0.00 sec)
.
select count(*) from ip_per_nat_vlan;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.00 sec)
.
show table status;
+----------------------------------+--------+---------+------------+----------+----------------+-------------+-----------------+--------------+------------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+----------------------------------+--------+---------+------------+----------+----------------+-------------+-----------------+--------------+------------+----------------+---------------------+---------------------+------------+-----------------+----------+----------------+---------+
| ip_per_nat_vlan | InnoDB | 10 | Dynamic | 141291 | 100 | 14172160 | 0 | 6832128 | 25165824 | 143563 | 2017-12-24 16:26:40 | 2018-06-13 09:01:33 | NULL | utf8_unicode_ci | NULL |
MySQL says, that there should be 14172160 rows, but I dont see any. Where could be a problem? Transactions? But I dont see any running thread and no any fault.
Thank you. D
Structure of table is:
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| ipAddress | varchar(255) | NO | UNI | NULL | |
| nat | int(11) | NO | | NULL | |
| vlan | int(11) | NO | | NULL | |
| district | varchar(255) | YES | | NULL | |
| idOblasti | int(11) | YES | | NULL | |
| type | varchar(255) | NO | | NULL | |
| macAddress | varchar(255) | NO | | NULL | |
+------------+--------------+------+-----+---------+----------------+
There are various ways to "count" rows in a table.
The normal way. Just count them.
select count(*) as table_rows from table_name ;
Accuracy: 100% accurate count at the time of the query is run.
using the information_schema tables
select table_rows
from information_schema.tables
where table_schema = 'database_name'
and table_name = 'table_name' ;
Accuracy: Only an approximation. If the table is the target of frequent inserts and deletes, the result can be way off the actual count. This can be improved by running ANALYZE TABLE more often.
Efficiency: Very good, it doesn't touch the table at all.
As count option is 100% accurate, your table doesn't contain any data.
Check your code and default commit option of MySQL.
Looks like you are inserting rows, but not committing them, check your index length.
Check more details here
https://dba.stackexchange.com/questions/151769/mysql-difference-between-using-count-and-information-schema-tables-for-coun
First thing, I am not sure how mysql run this line and produce the result
select count() from ip_per_nat_vlan
count() will return [Err] 1064.
count(*) or else a field name should be mentioned inside.
So here is the table status of my test table:
+------+--------+---------+------------+--------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+------+--------+---------+------------+--------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
| TEST | InnoDB | 10 | Compact | 172713 | 1175 | 203096064 | 202309632 | 0 | 5242880 | 181935 | 2015-07-21 23:52:24 | NULL | NULL | utf8_general_ci | NULL | | |
Table is created with:
CREATE TABLE TEST ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, att VARCHAR(1000) NOT NULL);
I heard from some one that Max_data_length used to be a fixed value and it is usually 4gb. But in later version of mysql they change the definition of Max_data_length. So now Max_data_length will grow as you insert more data (just like data_length).
I am wondering whats the new definition of Max_data_length and how is it different from Data_length?
Thanks!
Erben
I have accidentally deleted a .frm file for a test table. The problem is that I can not drop this table and remove it from information_schema.
select * from information_schema.tables where table_name like 'testtesttest';
+---------------+--------------+--------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+-----------------+----------+----------------+----------------------------------------------------------+
| TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | TABLE_TYPE | ENGINE | VERSION | ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | AUTO_INCREMENT | CREATE_TIME | UPDATE_TIME | CHECK_TIME | TABLE_COLLATION | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT |
+---------------+--------------+--------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+-----------------+----------+----------------+----------------------------------------------------------+
| def | report | testtesttest | BASE TABLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | Can't find file: './report/testtesttest.frm' (errno: 13) |
+---------------+--------------+--------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+-------------+-------------+------------+-----------------+----------+----------------+----------------------------------------------------------+
drop table report.testtesttest;
ERROR 1051 (42S02): Unknown table 'testtesttest'
Is there a way to tell mysql that such a table no longer exists?
Looks like that the following steps help:
touch /var/lib/mysql/report/testtesttest.{frm,ibd}
chown mysql:mysql /var/lib/mysql/report/testtesttest.frm
restart mysql
drop table report.testtesttest;
I uploaded a joomla website to my database some time ago. Now I would like to know what the exact date is that I uploaded the website. Is there a way to find this out in the database?
A quick way is to check the create_time or update_time when you execute this command:
show table status;
like the following example:
+--------------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+--------------------+--------+---------+------------+------+----------------+-------------+------------------+--------------+-----------+----------------+---------------------+---------------------+------------+-------------------+----------+----------------+---------+
| a_table | MyISAM | 10 | Dynamic | 2 | 60 | 120 | 281474976710655 | 1024 | 0 | NULL | 2011-09-08 18:26:38 | 2011-11-07 20:38:28 | NULL | latin1_swedish_ci | NULL | | |
I am sure there is another way to go about this but you can probably look inside the "data" folder and see the creation date of the mysql data files.