in eden • When eden fills up, stop-the-world and copy-collection into the survivor space • After several collections, survivors get tenured into old generation
total 4608000K, used 398455K eden space 4096000K, 0% used from space 512000K, 77% used to space 512000K, 0% used concurrent mark-sweep generation total 3072000K, used 1565157K concurrent-mark-sweep perm gen total 53256K, used 31889K }
4) - age 1: 137474336 bytes, 137474336 total - age 2: 37725496 bytes, 175199832 total - age 3: 23551752 bytes, 198751584 total - age 4: 14772272 bytes, 213523856 total
reclaimed in the young generation • Set –Xms==–Xmx (Heap growth or shrinking requires a Full GC) • Give young generation and survivor space large enough memory
size • -XX:MaxNewSize: max young generation size • -XX:NewRatio : young generation to old generation ratio • -XX:TargetSurvivorRatio: how much the survivor space should be filled • -XX:SurvivorRatio: eden to survivor size ratio …
from table_name where id = 1234 +----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+-------------------+---------+---------+-------+------+-------+
in (select id from t3 where id=1234 union all select id from t3) ; +----+--------------------+------------+--------+-------------------+---------+---------+-------+------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+--------------------+------------+--------+-------------------+---------+---------+-------+------+--------------------------+ | 1 | PRIMARY | t3 | ALL | NULL | NULL | NULL | NULL | 1000 | Using where | | 2 | DEPENDENT SUBQUERY | t3 | const | PRIMARY,idx_t3_id | PRIMARY | 4 | const | 1 | Using index | | 3 | DEPENDENT UNION | t3 | eq_ref | PRIMARY,idx_t3_id | PRIMARY | 4 | func | 1 | Using where; Using index | |NULL | UNION RESULT | <union2,3> | ALL | NULL | NULL | NULL | NULL | NULL | | +----+--------------------+------------+--------+-------------------+---------+---------+-------+------+--------------------------+
in (select id from t3 where id=1234 ) ; +----+--------------------+-------+-------+-------------------+---------+---------+-------+------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+--------------------+-------+-------+-------------------+---------+---------+-------+------+--------------------------+ | 1 | PRIMARY | t3 | index | NULL | PRIMARY | 4 | NULL | 1000 | Using where; Using index | | 2 | DEPENDENT SUBQUERY | t3 | const | PRIMARY,idx_t3_id | PRIMARY | 4 | const | 1 | Using index | +----+--------------------+-------+-------+-------------------+---------+---------+-------+------+--------------------------+
type(ordered from the best to the worst) 1. system 2. const 3. eq_ref 4. ref 5. ref_or_null 6. index_merge 7. unique_subquery 8. index_subquery 9. range 10. index 11. ALL