I'm noticing that there is overhead added to the lead and lead_detail tables upon each form submission. I'm only using one form right now.
Because I'm filing to a custom post type, I don't want the form entries to be saved. So I am using the following function to delete them:
function remove_form_entry($entry, $form){
global $wpdb;
$lead_id = $entry['id'];
$lead_table = RGFormsModel::get_lead_table_name();
$lead_notes_table = RGFormsModel::get_lead_notes_table_name();
$lead_detail_table = RGFormsModel::get_lead_details_table_name();
$lead_detail_long_table = RGFormsModel::get_lead_details_long_table_name();
//Delete from detail long
$sql = $wpdb->prepare(" DELETE FROM $lead_detail_long_table
WHERE lead_detail_id IN(
SELECT id FROM $lead_detail_table WHERE lead_id=%d
)", $lead_id);
$wpdb->query($sql);
//Delete from lead details
$sql = $wpdb->prepare("DELETE FROM $lead_detail_table WHERE lead_id=%d", $lead_id);
$wpdb->query($sql);
//Delete from lead notes
$sql = $wpdb->prepare("DELETE FROM $lead_notes_table WHERE lead_id=%d", $lead_id);
$wpdb->query($sql);
//Delete from lead
$sql = $wpdb->prepare("DELETE FROM $lead_table WHERE id=%d", $lead_id);
$wpdb->query($sql);
}
add_action('gform_after_submission_1', 'remove_form_entry', 10, 2);
Does that have anything to do with it? How does this affect performance? I know optimization of the database tables is something that should be done as part of maintenance, but will I need to monitor this all the time especially if I notice lag time on the site?