Skip Navigation

[Resolved] Question about SQL queries

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years, 12 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 3 replies, has 2 voices.

Last updated by steveC-5 7 years, 12 months ago.

Assisted by: Nigel.

Author
Posts
#462130

Good Evening,

Had a question about some queries we are seeing the Types plugin call on the post.php edit screens.

1)

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
WHERE 1=1
AND wp_posts.post_type = 'show'
AND (wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'future'
OR wp_posts.post_status = 'draft'
OR wp_posts.post_status = 'pending'
OR wp_posts.post_status = 'private')
ORDER BY wp_posts.post_date DESC
LIMIT 0, 1 /* in [/nas/content/live/jambase3/wp-content/plugins/types/application/models/helper/condition/type/fields_assigned.php:13] */

2) SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
WHERE 1=1
AND wp_posts.post_type = 'show'
AND (wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'future'
OR wp_posts.post_status = 'draft'
OR wp_posts.post_status = 'pending'
OR wp_posts.post_status = 'private')
ORDER BY wp_posts.post_date DESC
LIMIT 0, 1 /* in [/nas/content/live/jambase3/wp-content/plugins/types/application/models/helper/condition/type/fields_assigned.php:13] */

3) SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
WHERE 1=1
AND wp_posts.post_type = 'show'
AND ((wp_posts.post_status = 'publish'))
ORDER BY wp_posts.post_date DESC
LIMIT 0, 1 /* in [/nas/content/live/jambase3/wp-content/plugins/types/application/models/helper/placeholder.php:200] */

1 & 2 seem to be duplicates.

The Trace on 1 & 2 is:

WP_Query->get_posts-
WP_Query->query
WP_Query->__construct
Types_Helper_Condition_Type_Fields_Assigned->valid
Types_Helper_Condition_Single_No_Fields->valid
Types_Information_Message->valid
Types_Information_Table->add_message
Types_Information_Controller->load_data_to_table
Types_Information_Controller->show_data_as_table_in_meta_box
Types_Information_Controller->prepare
Types_Page_Extension_Edit_Post->prepare_information
Types_Page_Extension_Edit_Post->prepare
Types_Page_Extension_Edit_Post->__construct
Types_Page_Extension_Edit_Post::get_instance
call_user_func_array
do_action('load-post.php')
require_once('wp-admin/admin.php')

The trace on 3 is:

WP_Query->get_posts-
WP_Query->query
WP_Query->__construct
Types_Helper_Placeholder::get_archive_permalink
Types_Helper_Placeholder::replace
Types_Information_Controller->show_data_as_table_in_meta_box
Types_Information_Controller->prepare
Types_Page_Extension_Edit_Post->prepare_information
Types_Page_Extension_Edit_Post->prepare
Types_Page_Extension_Edit_Post->__construct
Types_Page_Extension_Edit_Post::get_instance
call_user_func_array
do_action('load-post.php')
require_once('wp-admin/admin.php')

On our pages these queries are accounting for about 4 seconds of the page's 7 second load time [we have hundreds of thousands of posts in this custom post type].

We ran all three of these queries on the command line and each time it simply produced the most recent Post ID in that custom post type - which we are unclear why the plugin/post needs in the first place.

Any guidance on how these queries are used - and if there is anything we can do to suppress them would be greatly appreciated.

Thank you so much.

#462378

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm not sure how much help I can be but can you tell me more about the custom post type.

If I create a custom post type with Types and do nothing else but create a sample post and then edit that post, using Query Monitor to see the queries run on that page I only see one query such as you describe above (which I think is the final one).

Do you have post relationships and/or custom fields set up on this post type, too?

#462497

Hi Nigel, thanks for your reply!

Yes - our "shows" custom post type does have custom fields - and does have one parent post type "Venue" and 3 children post types "Performance" ; "Ticketing Link" ; and "Contest"

#463371

Just a quick note on this thread [I am going to mark it as resolved] - as I have moved it over to the Professional Support forums after upgrading our membership.

Thanks!

The forum ‘Types Community Support’ is closed to new topics and replies.