Hi there,
I have a quick question relating to my earlier support ticket (Views print pagination).
Using the get_view_query_results(), is there a way to avoid overloading the site when producing a large amount of results?
We're displaying 2,000 or so car owners and keep running out of memory. I can keep increasing the memory, but wanted to see if there was a better way? breaking down the request into chunks, etc.
I look forward to your thoughts.
Kind Regards
James
Yes, pagination is usually a good way to break down a query into manageable chunks. You can use "limit" and "offset" in your arguments array as defined in the View shortcode documentation here to retrieve paginated result blocks: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view
Hi Christian, many thanks for your quick response. I use pagination for displaying the page results, but would this work for print/pdf output?
We want to provide print/pdf/csv links on the results pages and my issue so far has been that they only apply to the visible page.
We need to be able to print all pages from the results and, in some cases, there may be 30 - 40 pages.
I look forward to your thoughts.
Kind regards
James
Views is optimized for displaying data onscreen, not generating massive reports like this. If I were trying to do something similar, I would try to generate a report directly from the database. To come up with the right query, you could use pagination with your get_view_query_results call. Turn on the Views debug tool in Toolset > Settings > Front-end Content, and it will display the paginated MYSQL query when the page is loaded. Then you can remove the LIMIT and OFFSET parameters and run the query directly on the database. Trying to get all these results on the front-end of the site is going to be impractical and probably not possible given WordPress and browser limitations.
Many thanks Christian, we followed your advice and went for a direct db search.
Much appreciated.
Kind regards
James