Reset Entry ID to 1 [RESOLVED]

(There’s another thread with a similar title, but it’s not relevant.)

My entry IDs have gone above 30k and it’s causing problems elsewhere. How can I reset the autoincrement back to 1? Then I won’t have this problem for another 30.000 entries. :slight_smile:

What kind of problems is the entry ID over 30K causing for you?

Oh boy does that mean there’s no simple value I can reset in the db? :slight_smile:

It’s related to 3rd party APIs where we’ve used the entryID as a uniqueID in a handful of different situations. Rather than hunting down and adjusting all those situations it seems easiest to ‘fix’ the problem at the source and start from 1.

If you reset the entry ID back to one, you will need to remove all your existing entries and related entry data. Are you OK with that?

Yes absolutely. We purge our entries after 24 hours, so we’ve got about 30 entries at the moment, with IDs in the 30.000s. Totally fine to delete.

You’re just saying there can’t ever be duplicate entry IDs. So even if we didn’t purge all entries before resetting, as long as they weren’t close to the current entry IDs we’d be fine?

Ok, last question, I think. Are all entries for all forms deleted? If so, you will be able to reset the entry ID back to 1. Otherwise, this won’t work, because the entry ID is sequential across all forms.

Gotcha, appreciate you being so thorough as always Chris!

Yes, we have a handful of forms but all entry IDs are in the 30k range.
Resetting to zero wouldn’t result in duplicate IDs for some time, and by then the old entries will have been auto purged.

I don’t think this will work if you are going to retain some entries with higher entry IDs. MySQL won’t allow you to set an autoincrement value lower than a record already in the table. So if you have entries there with higher IDs already, you would not be able to do this anyway.

ref: sql - How to reset AUTO_INCREMENT in MySQL - Stack Overflow

I would focus on fixing the other end that cannot handle the higher entry IDs.

Thanks Chris, I’d rather delete the higher entry IDs and start fresh. Thanks!
What is the table where this is stored for GF?

Gravity Forms entry-related data is stored in three tables. If your WordPress database prefix is wp_, these are the tables:


If you have deleted all the entries, you should have no records in any of those tables.

The autoincrement for the entry ID is on the wp_gf_entry table. You can find out what that is currently using this SQL:


That shows a bunch of columns, one of which is Auto_increment.

To reset that, first, please make a database backup, in case something goes horribly wrong. This worked for me with my MySQL database installation and version, but your may be different. Please make a database backup first.

To reset the auto_increment for the wp_gf_entry, this is the SQL command to execute:


Then run the previous command SHOW TABLE STATUS LIKE 'wp_gf_entry'; to check to see the new auto_increment value.

That showed “1” for me, so that worked, and the next entry that will be stored with one of your forms will get the entry ID 1.

Like I mentioned, make a database backup first. We can’t be held responsible for anything which may go wrong here. Let us know how it turns out.

Disclaimer : Third party plugins or code snippets that are provided or referenced by our Support Team or documentation, are provided as suggestions only. We do not evaluate, test, guarantee or officially support third party solutions or code-snippets. You are wholly responsible for determining if any suggestion or code snippet provided is sufficient to meet the functional, security, legal, ongoing cost and support needs of your project, as well as testing and confirming performance across future product updates.

1 Like

Thanks Chris, that worked beautifully.

1 Like