Skip Navigation

[Résolu] Users Views & Pagination Issue

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
I am doing some tests to my development website with views and I discovered sth wird. I need to create user profiles and I am testing if it is faster and lighter to use a post view or a user view.

So here is how I did my test: I added 2.741 users to my website and 2.741 posts. Then I created a post view and a user view with exactly the same fields. According to query monitor, the user View needs 3.8 sec to generate the page (196 KB) when the post view needs 6.36 sec (188 KB). Big difference, right?

When I paginated my views sth very strange happened. The user view now needs 2.34 sec from 3.8 sec (188 KB) to create the page when the post view needs just 0.2 sec (13 KB) from 6.36 sec (188 KB)

Why may this is happening? Why the post view has so big difference when it is paginated and the user view remains almost the same? Is this a bug or am I missing a setting?

I am developing a site that may be huge in the future with a lot of users registered to it, so I would like to avoid adding extra content that is not needed. Ideally I would like to use just the user view without adding extra custom fields and custom post type for the creation of the profiles. Is there a way to make the user view faster like is happening with the post view when it is paginated?

Solution:
Q1) Why may this is happening? Why the post view has so big difference when it is paginated and the user view remains almost the same? Is this a bug or am I missing a setting?
There are lots of differences between them, the main difference is below
Views uses wordpress class WP_Query to query the posts in database table "wp_posts"
https://codex.wordpress.org/Class_Reference/WP_Query

and uses WP_User_Query to query the users in tatabase table "wp_users"
https://codex.wordpress.org/Class_Reference/WP_User_Query

1) In the database table "wp_posts", there are lots number of columns
https://codex.wordpress.org/Database_Description#Table:_wp_posts
for example column "post_content" is a "longtext" type column,
But in table "wp_users", there are less number of columns, and without "longtext" type column
https://codex.wordpress.org/Database_Description#Table:_wp_users

2) The class WP_Query support cache feature:
https://codex.wordpress.org/Class_Reference/WP_Query#Caching_Parameters
but there isn't cache feature within class WP_User_Query

So it conducts the issues you mentioned above.

Q2) Is there a way to make the user view faster like is happening with the post view when it is paginated?
There are some documents you can refer:
1) shortcode [wpv-view]:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-view
Turn on cache feature of Views plugin:
cached (opt): off
Turns off the caching system for the View.
For example: [wpv-view ...cached="on"]

2) How to Use Views Custom Search on Large Sites
https://toolset.com/documentation/user-guides/front-page-filters/how-to-use-views-parametric-search-on-large-sites/

3) Working with Caching Plugins
https://toolset.com/faq/working-with-caching-plugins/

Relevant Documentation:
https://toolset.com/documentation/user-guides/front-page-filters/how-to-use-views-parametric-search-on-large-sites/
https://toolset.com/faq/working-with-caching-plugins/

This support ticket is created Il y a 6 années et 4 mois. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 2 réponses, has 2 voix.

Last updated by ioannisM-2 Il y a 6 années et 4 mois.

Assisted by: Luo Yang.

Auteur
Publications
#598288
USERS QUERY.png
POSTS QUERY.png

Hello,

I am doing some tests to my development website with views and I discovered sth wird. I need to create user profiles and I am testing if it is faster and lighter to use a post view or a user view.

So here is how I did my test: I added 2.741 users to my website and 2.741 posts. Then I created a post view and a user view with exactly the same fields. According to query monitor, the user View needs 3.8 sec to generate the page (196 KB) when the post view needs 6.36 sec (188 KB). Big difference, right?

When I paginated my views sth very strange happened. The user view now needs 2.34 sec from 3.8 sec (188 KB) to create the page when the post view needs just 0.2 sec (13 KB) from 6.36 sec (188 KB)

Why may this is happening? Why the post view has so big difference when it is paginated and the user view remains almost the same? Is this a bug or am I missing a setting?

I am developing a site that may be huge in the future with a lot of users registered to it, so I would like to avoid adding extra content that is not needed. Ideally I would like to use just the user view without adding extra custom fields and custom post type for the creation of the profiles. Is there a way to make the user view faster like is happening with the post view when it is paginated?

If you need to have a look to the live pages the links are:
mydomain.xx/en/view-post-query-test/
mydomain.xx/en/view-post-query-paginated
mydomain.xx/en/view-user-query-test/
mydomain.xx/en/view-user-query-paginated/

#598322

Dear Ioannis,

Q1) Why may this is happening? Why the post view has so big difference when it is paginated and the user view remains almost the same? Is this a bug or am I missing a setting?
There are lots of differences between them, the main difference is below
Views uses wordpress class WP_Query to query the posts in database table "wp_posts"
https://codex.wordpress.org/Class_Reference/WP_Query

and uses WP_User_Query to query the users in tatabase table "wp_users"
https://codex.wordpress.org/Class_Reference/WP_User_Query

1) In the database table "wp_posts", there are lots number of columns
https://codex.wordpress.org/Database_Description#Table:_wp_posts
for example column "post_content" is a "longtext" type column,
But in table "wp_users", there are less number of columns, and without "longtext" type column
https://codex.wordpress.org/Database_Description#Table:_wp_users

2) The class WP_Query support cache feature:
https://codex.wordpress.org/Class_Reference/WP_Query#Caching_Parameters
but there isn't cache feature within class WP_User_Query

So it conducts the issues you mentioned above.

Q2) Is there a way to make the user view faster like is happening with the post view when it is paginated?
There are some documents you can refer:
1) shortcode [wpv-view]:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-view
Turn on cache feature of Views plugin:
cached (opt): off
Turns off the caching system for the View.
For example: [wpv-view ...cached="on"]

2) How to Use Views Custom Search on Large Sites
https://toolset.com/documentation/user-guides/front-page-filters/how-to-use-views-parametric-search-on-large-sites/

3) Working with Caching Plugins
https://toolset.com/faq/working-with-caching-plugins/

#598726

Oh, that was very clarifying, thank you Luo!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.