PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

MySQL Performance Issue - SELECT count(0) statements

  1. I have a site using the Gravity Forms plugin.

    I am noticing a significant mysql performance issue. I have done everything I can to tweak the MySQL database settings to gain performance.

    I am constantly seeing several SQL statements similiar to this:

    SELECT count(0) FROM wp_posts WHERE post_title='Untitled_2597'

    There are often 10 different types of these select statements and then run continuously. Can someone shed light as to if this is normal and if not or if there is a way I can curb these count(0) statements I would really appreciate it. It's killing my site.


    Posted 10 years ago on Wednesday May 11, 2011 | Permalink
  2. We are still looking for urgent assistance with this matter. Our entire server is being choked by these count(0) statements.

    Posted 10 years ago on Thursday May 12, 2011 | Permalink
  3. That MySql command is executed when you have a form that has a post field, but not a post title field. It does that to come up with an unique post title. If you have lots of posts with name Untitled_1, Untitled_2, Untitled_3, etc... It is possible that every time your form is submitted, it will execute that sql statement many times until it finds an unique post title to use.
    My suggestion is to simply add a post title to your form. You can pre-populate it with variables from the form and mark it as admin only so that it doesn't get displayed in the front end form.

    I hope this helps.

    Posted 10 years ago on Thursday May 12, 2011 | Permalink
  4. To follow up on what Alex said, you most likely have a lot of "Untitled" posts because your form is creating posts and never using a Title so you probably have an "Untitled" Post for every form entry... which could be a lot.

    Why is your form configured to create a Post but without using the Post Title field? Doesn't make much sense to use a form to create a post with no Title. You may be using a Post Body field by accident. If you use Post Fields from the Post Field group of fields in the Form Editor, these should only be used if you want your form to create a Post. But Posts should have a Title so you need to use the Post Title field, your form does not have one otherwise this query wouldn't be executing.

    Posted 10 years ago on Thursday May 12, 2011 | Permalink
  5. Carl,

    Our forms did have Post Titles but was not required. I have since selected the 'Required' field in hopes that this prevents blank Post Titles.

    Posted 10 years ago on Thursday May 12, 2011 | Permalink