I have noticed that lately any time I add a category or a tag through the admin, it ends up with a nutty, exponentially larger term_id in $wpdb->terms, like so:
| 48 |
| 49 |
| 50 |
| 51 |
| 52 |
| 847 |
| 3797 |
| 5678 |
| 9063 |
| 11852 |
| 12200 |
| 14519 |
| 14797 |
| 18097 |
| 19058 |
| 20353 |
| 22471 |
| 23128 |
The jump to a 5 and soon 6 digit ID is happening a little too quickly for comfort. Curious as to why this was happening, i tracked the code to the function "wp_insert_term" in the file "wp-includes/taxonomy.php". The cause seems to be lines 942-944:
$maxterm = $wpdb->get_var( "SELECT max(term_id) FROM {$wpdb->terms}" );
$term_id = mt_rand( $maxterm+100, $maxterm+4000 );
$wpdb->query("INSERT INTO $wpdb->terms (term_id, name, slug, term_group) VALUES ('$term_id', '$name', '$slug', '$term_group')");
Why is it that a crazy number has to be generated for the insert instead of just incrementing?