Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 0.7.8.1
- This topic has 15 replies, 2 voices, and was last updated 11 years, 10 months ago by
owdbuzmjcb.
-
AuthorPosts
-
09/10/2013 at 3:53 pm #268909
Aredon
GuestContinuing conversation from: http://wordpress.org/support/topic/many-categories-max_execution_time-problems?replies=3#post-4635651
So I’m working on a solution for a client that needs to have people organized by state/county. So I set up connections to have 51 parent categories (states), and their counties. I wrote a script to very carefully load these into the connections databases.
Currently there are 3150 categories, and as much as I would like to reduce this number I can’t. I’ve had to modify the max_execution_time to be a full minute in order to get the connections plugin to load its category list. Furthermore once it does load the page hangs for quite a while before I am able to interact with it.
On the front end there is a dropdown where users pick state, then county, and it shows all the entries that match.
Is there a way that categories could be streamlined a little bit more? Or perhaps better organized (paginated?) so that individuals who need a lot of categories can use your plugin? Or is there a better solution using this plugin that I am not aware of. I am open to suggestions.
I knew eventually I’d have to starting worrying about caching them and caching the rendered HTML so it could be loaded more quickly.
On the frontend, is that something you’ve custom coded?
I have a couple ideas that may work … could we take this conversation over to my support forum please?
The front end is a custom template, yes. It’s also a custom query pulling from the connections databases. The front end is working perfectly. It is unfortunately the connections plugin on the backend that is the issue currently.
09/10/2013 at 3:59 pm #268911Aredon
GuestFront-end code for your benefit.
##Unfortunately connections does not currently allow us (as far as I know) to get a list of all the categories, and we need them. So we're going to fetch them manually. This is likely to break at some point when the plugin's database gets changed in an update. //set up wpdb class global $wpdb; //get parent-child relationships $sql = "SELECT <code>term_id</code>,<code>parent</code> FROM <code>".$wpdb->prefix."connections_term_taxonomy</code>"; $taxonomy = $wpdb->get_results($sql); //grab names $sql = "SELECT * FROM <code>".$wpdb->prefix."connections_terms</code>"; $names_raw = $wpdb->get_results($sql); //organize this a little better foreach($names_raw as $name){ $names[$name->term_id]['name'] = htmlentities($name->name,ENT_QUOTES); $names[$name->term_id]['slug'] = htmlentities($name->slug,ENT_QUOTES); } //sort through the taxonomies, grab their names, and build a list $tier = array(); foreach($taxonomy as $tax){ //make sure we have a name for the parent (otherwise it's root) if(!empty($names[$tax->parent]['slug']) && isset($names[$tax->parent]['slug'])){ $tier[$tax->parent]['children'][$tax->term_id] = $names[$tax->term_id]; }else{ $tier[$tax->term_id] = $names[$tax->term_id]; } } //now that we're all organized, let's make a dropdown! unset($tier[1]); //remove uncategorized $tier = array_filter($tier); echo '<form method="get">'; echo '<select name="state" onchange="this.form.submit()">'; echo '<option value="0">Select...</option>'; //create our options (state level) foreach($tier as $category_id => $state_data){ $selected = ''; if(intval($_GET['state'])===$category_id)$selected = 'selected="selected"'; echo '<option value="'.$category_id.'" '.$selected.'>'.$state_data['name'].'</option>'; } echo '</select>'; //if we know the state, get counties if(isset($_GET['state']) && !empty($_GET['state']) && is_numeric($_GET['state'])){ echo '<select name="county" onchange="this.form.submit()">'; echo '<option value="0">Select...</option>'; foreach($tier[$_GET['state']]['children'] as $id => $county){ $selected = ''; if(intval($_GET['county'])===$id)$selected = 'selected="selected"'; echo '<option value="'.$id.'" '.$selected.'>'.$county['name'].'</option>'; } echo "</select>"; } echo '</form>'; if(isset($_GET['county']) && !empty($_GET['county'])){ echo do_shortcode('[connections category="'.intval($_GET['county']).'"]'); }09/11/2013 at 2:04 pm #268997Steven Zahm
Keymaster@
So the front end works fine with you custom code. That’s good. Where does it break in the admin? I image the Connections : Manage page is fine because that is pagination. I could see the Connections : Categories page being problematic with so many categories. I’m think the Add / Entry page should be alright, especially if your front end code is fine.
There is a method you can call to create a category select:
cnTemplatePart::category( array( 'default' => 'Select...', 'type' => 'select', 'group' => TRUE, 'parent_id' => $category_state_ID ));However, I don’t think it work with you chained select. I’d have to tweak the code in order to support that better.
09/12/2013 at 3:06 pm #269067Aredon
GuestThanks for the reply,
Actually all three pages you listed have load speed issues with this many categories. Don’t worry about adding code to support what I did on the front-end (chained select). I just need the plugin to be faster on the back-end so that entries and categories can be managed properly.Prior to increasing the load time:
Fatal error: Maximum execution time of 30 seconds exceeded in /wp-content/plugins/connections/includes/class.terms.php on line 144
Here’s the page load times:
Here’s the dashboard as a control:
As you can see the categories are adding a good 30+ seconds of load time.
09/13/2013 at 4:07 pm #269146Steven Zahm
Keymaster@ Aredon
Could you add a screen capture of your page with the custom query. I image it’s much quicker because you are not joining the taxonomy tables.
Also, could I get a sql export off the following tables?
connections_terms
connections_term_taxonomy
connections_term_relationships09/20/2013 at 3:09 pm #269645Aredon
GuestI suppose I don’t really see how this helps you but here you go?
CSVs as requested
https://dl.dropboxusercontent.com/u/8244471/wp_connections_term_relationships.csv
https://dl.dropboxusercontent.com/u/8244471/wp_connections_term_taxonomy.csv
https://dl.dropboxusercontent.com/u/8244471/wp_connections_terms.csv09/21/2013 at 9:06 am #269670Steven Zahm
Keymaster@ Aredon
Sorry, what I meant was a screenshot showing the loading time of the page that includes you custom query.
Thanks for the CSV files. I’ll import them in my test setup to see if I can duplicate and what tweaks I can implement for better performance.
09/24/2013 at 8:30 pm #269895Aredon
GuestRoughly 2 seconds load time total
10/01/2013 at 1:36 pm #270451Aredon
GuestHello sir, any word on this yet? My client is going to want me to have a solution very soon. I don’t mean to rush you but I need to know if you’ve come up with anything so I can decide whether or not I need to develop something entirely different.
10/02/2013 at 11:51 am #270503Steven Zahm
Keymaster@ Aredon
Sorry, no, I have not made any progress in seeing if I can improve the performance in the core. The only real difference I see between your custom code and the code used in the admin pages is that I use a left join to query the data in a single query rather than the two you’re using. Another difference is the core code builds the category array for n-deep child relationships; your goes just one – parent/child. I can’t know for sure until I do some real solid performance analysis but I can’t see either would be faster than the other.
I’m thinking this comes all down to the browser rendering speed and/or the time to create the HTML in PHP. What I’m doing on the admin pages is definitely “heavier” than your code.
You could verify the query times by installing Debug Bar and comparing the query times on the pages.
-
AuthorPosts
- You must be logged in to reply to this topic.
