Home › Toolset Professional Support › [Resolved] Maps View performance poor with >700 entries
Problem:
Maps View performance poor with >700 entries
Solution:
Well - 700+ entries is a lot to display with single request.
You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/maps-view-performance-poor-with-700-entries/#post-921251
Relevant Documentation:
=> https://toolset.com/documentation/user-guides/front-page-filters/how-to-use-views-parametric-search-on-large-sites/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
Tagged: Toolset Maps, Views plugin
Related documentation:
This topic contains 15 replies, has 3 voices.
Last updated by cortJ 6 years, 6 months ago.
Assisted by: Minesh.
We want to display a large number of entries via maps plugin (see zerowastemap.org). At the moment there are about 800 and it takes up to 30 seconds to render the page. We use caching so it doesn't affect most visitors too much, but the numbers are growing and we want to achieve a better performance.
We are already using all types of caching like PHP Opcode/APCu, database cache, object cache and so on.
Problem: In the main loop a custom field is queried to choose the right maps marker icon as follows:
marker_icon='hidden link type="location-type" format="slug"][wpv-conditional if="( $(wpcf-status-operation) eq 2 ) OR ( empty($(wpcf-status-operation)) )" evaluate="false"]_bw[/wpv-conditional].png'
This seems to lead to many nested database queries and makes the process very slow. Without that dynamic marker_icon part the execution time is about 10 times faster.
Is there a way to use a custom database query and/or custom shortcode to query the required post data and metadata (taxonomy location-type, wpcf-status-operation) all in one step? Or other options to further improve the performance? To me it seems to be a pure design issue, when everything is done piece by piece via shortcodes, it doesn't go together with 'mass data' very well.
Here's the full code of our maps view loop:
[wpv-layout-start]
[wpv-map-render map_id="map-1" fitbounds="on" map_type_control="off" map_height="90vh" single_zoom="10" cluster="on" spiderfy="on" cluster_grid_size="30" cluster_max_zoom="10"][/wpv-map-render]
[wpv-items-found]
[wpv-map-marker map_id="map-1" marker_id="marker-a" marker_icon="//zerowastemap.org/wp-content/uploads/zerowastemap/visitor_bw.png" address='[wpv-search-term param="center"]'][wpv-search-term param="center"][/wpv-map-marker]
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]" marker_icon='hidden link type="location-type" format="slug"][wpv-conditional if="( $(wpcf-status-operation) eq 2 ) OR ( empty($(wpcf-status-operation)) )" evaluate="false"]_bw[/wpv-conditional].png' marker_field="wpcf-location-address"]
<div>[wpv-post-title output="sanitize"]</div>
<div>[types field='location-address'][/types]</div>
<div>[wpml-string context="wpv-views"]Category:[/wpml-string] [wpv-post-taxonomy type="location-type" format="name"]</div>
<div>
</div>
[/wpv-map-marker]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpv-map-marker map_id="map-1" marker_id="marker-a" marker_icon="//zerowastemap.org/wp-content/uploads/zerowastemap/visitor_bw.png" address='[wpv-search-term param="center"]'][wpml-string context="wpv-views"]Nothing found in[/wpml-string] [wpv-search-term param="center"][/wpv-map-marker]
[/wpv-no-items-found]
[wpv-layout-end]
Thanks,
Sebastian
Hello. Thank you for contacting the Toolset support.
Well - you said that you see a major issue with the following code:
marker_icon='<em><u>hidden link</u></em> type="location-type" format="slug"][wpv-conditional if="( $(wpcf-status-operation) eq 2 ) OR ( empty($(wpcf-status-operation)) )" evaluate="false"]_bw[/wpv-conditional].png'
could you please share problem URL and access details so I will check what we can do here - if we can replace the above conditional statement with shortcode it would be good as well.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).
I have set the next reply to private which means only you and I have access to it.
Thank you for sharing access details but when I tried to access the login page, it asks me the authorization access details.
Could you please share authorization access details.
I have set the next reply to private which means only you and I have access to it.
First of all - After checking debug information you shared with us, I found that you are using outdated Toolset + WPML plugins.
We always recommend to run your site with latest stable release plugin version. Do you have any reason to keep using outdated plugins? If no:
*** Please make a FULL BACKUP of your database and website.***
Could you please update ALL Toolset plugins to it's latest official released version. You can download latest plugin release from your accounts page:
=> https://toolset.com/account/downloads/
Additionally, just to point you out, the last release with Types 3.0 was a major release with lots of features added. You can see here - Please read following blogs:
=> https://toolset.com/2018/05/toolset-post-relationships-release/
=> https://toolset.com/2018/05/when-if-to-migrate-relationships-in-old-toolset-sites/
Now, if you just want to me to fix the issue with the current site as it is to check and add shortcode I need FTP access. Please share FTP access details.
I have set the next reply to private which means only you and I have access to it.
Toolset is now up to date, WPMP deactivated to make it easier.
Main questions now are:
1. Why are there two admin-ajax requests performed on each filter-change (one when a user picks a 'category', and another one as soo as they hit 'submit')? The view is set to update only on 'submit'.
2. How can the scaling problem be avoided where it takes 10 to 30 seconds already to load ~700 entries. From what I see the time will double as soon as the number of entries doubles.
Thank you,
Sebastian
Sorry, forgot to mention that I changed the domain name to hidden link in order to get SSL running!
Thanks.
1. Why are there two admin-ajax requests performed on each filter-change (one when a user picks a 'category', and another one as soo as they hit 'submit')? The view is set to update only on 'submit'.
==> Would you mind to open a new ticket with your each new question. As this will help other users searching on the forum and help us to write correct ticket resolution summery for original issue.
2. How can the scaling problem be avoided where it takes 10 to 30 seconds already to load ~700 entries. From what I see the time will double as soon as the number of entries doubles.
==> I need FTP access details to add shortcode to check if that makes any difference in performance. Could you please share FTP access details.
I have set the next reply to private which means only you and I have access to it.
Well - I'm bit confused. You said you changed the domain name to hidden link in order to get SSL running!
So - will the FTP access you shared will work for the above changed domain?
Yes the credentials and host name shared via secure form will work (it's a virtual server with different host name for FTP).
Well - I've added following custom shortcode to your current theme's functions.php file:
add_shortcode( 'get_marker_icon', 'func_get_marker_icon' ); function func_get_marker_icon( $atts ) { global $post; $term = wp_get_object_terms( $post->ID, 'location-type', array( 'fields' => 'slugs' ) ); $so = get_post_meta($post->ID,'wpcf-status-operation',true); if(!empty($term)){ $term_slug = $term[0]; } $str = ''; if($so !=2 or $so != ''){ $str = '_bw'; } $return = $term_slug.$str.'.png'; return $return; }
Now, inside your view, rather calling two shortcode for taxonomy and conditional shortcode, I'm calling the single shortcode as given under:
[wpv-map-marker map_id="map-1" marker_id="marker-[wpv-post-id]" marker_icon='<em><u>hidden link</u></em>' marker_field="wpcf-location-address"]
I also registered the <Strong> get_marker_icon shortcode at: Toolset => Settings => Front-end Content => Third-party shortcode arguments
Do you see any performance difference now?
However, let me tell you something 700+ entries is a lot to display with single request. I also suggest you to look at following Doc:
=> https://toolset.com/documentation/user-guides/front-page-filters/how-to-use-views-parametric-search-on-large-sites/
Thanks for your help! Unfortunately it doesn't seem to make any noticable difference, maybe the internal number of database queries is more or less the same, I didn't count that yet.
As for your suggestion, toolset caching is active but doesn't seem to apply here because of the conditions mentioned in your link.
Filtering on RELEVANT map items would be a great approach. Most logical would be a filter on the visible map coordinates, but as far as I can tell that's not available by now, right? With that sort of filter, where only those entries are loaded which will also appear inside of the viewport, the maps plugin would become much more useful with larger numbers of entries. We could then limit the minimum zoom level to reduce the number of map points loaded. On each scroll or zoom event the maps plugin would have to load the new set of entries and eventually merge it with the data already loaded.
Is that something that can be expected in the near future? Alternatively, the distance filter could be used to achieve something like this when coupled to the zoom level. Do you see any way to achieve this?
If not, the only solution would be to not use the maps plugin but instead create something with viewport filtering by hand.
Thanks,
Sebastian
Filtering on RELEVANT map items would be a great approach. Most logical would be a filter on the visible map coordinates, but as far as I can tell that's not available by now, right? With that sort of filter, where only those entries are loaded which will also appear inside of the viewport, the maps plugin would become much more useful with larger numbers of entries. We could then limit the minimum zoom level to reduce the number of map points loaded. On each scroll or zoom event the maps plugin would have to load the new set of entries and eventually merge it with the data already loaded.
==> Do you mean filter by current location of user by default when page loaded?
I mean both cases - no matter if the device geolocation is present or if a default map center is shown. The map should filter on those points which are located within the visible map area (which is defined by lng. lat coordinates as well). As google and other mapping services do, they dynamically load only those points which will appear in the visible area.
No - unfortunately, there is no such feature available. So, now you should make decision. 🙂
I see ... so please give my feature request a strong upvote 🙂