View previous topic :: View next topic |
Author |
Message |
sangprabv Smarty Rookie
Joined: 14 Feb 2005 Posts: 13 Location: Jakarta
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Sep 04, 2009 9:55 pm Post subject: |
|
|
Use your PHP $_SESSION to retain query info, don't pass that through the URL. |
|
Back to top |
|
sangprabv Smarty Rookie
Joined: 14 Feb 2005 Posts: 13 Location: Jakarta
|
Posted: Sat Sep 05, 2009 1:51 am Post subject: |
|
|
use $_SESSION? You mean create a new session to handle the query result? For each $_GET? or the whole $_REQUEST? Can you help me to provide some examples? TIA |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Sep 06, 2009 1:32 am Post subject: |
|
|
If you are using SmartyPaginate, then you must be using php sessions already. So instead of passing the query through the URL to the client and back, just keep it in the sever-side session instead. This is much more secure anyways. So:
Code: | $_SESSION['query'] = 'select * from foo'; |
On every subsequent pagination, $_SESSION['query'] will be there for you. |
|
Back to top |
|
stot Smarty Rookie
Joined: 13 Nov 2006 Posts: 17
|
Posted: Sat Dec 05, 2009 11:40 pm Post subject: internal pagination data is growing |
|
|
mohrt wrote: |
2) No, the examples are just using arrays as the source data. You would normally be using SQL with query limits set. |
Hi Mohrt,
rather than the sql result, I meant the pagination array that is handed over to smarty. here is a snippet of my Smarty Debug Console:
Code: |
{$paginate} Array (13)
total => 5789
first => 1
last => 15
page_current => 1
page_total => 386
size => 14
url => "/search?searchstring=creme&sort=&order="
urlvar => "next"
current_item => 1
prev_text => "prev"
next_text => "next"
limit => 15
page => Array (386)
1 => Array (4)
number => 1
item_start => 1
item_end => 15
is_current => true
2 => Array (4)
number => 2
item_start => 16
item_end => 30
is_current => false
+++ here are _all_ pages between 2 and 385 +++
385 => Array (4)
number => 385
item_start => 5761
item_end => 5775
is_current => false
386 => Array (4)
number => 386
item_start => 5776
item_end => 5789
is_current => false
|
The number of total results is 5789, pages 386.
A full array with page related information, such as number, start, end, current is created and handed over to smarty. This will slow down the rendering process, since all the data needed to be created and submitted to smarty. Not to mention memory usage. I have several categories with tens of thousands of entries.
Would it be possible to create only the slice of the array which is needed for display?
Any comments would be apprechiated,
thanks, stot |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Dec 05, 2009 11:46 pm Post subject: |
|
|
You should only pass the data that is for display (the current page). Maybe I don't understand what you're trying to do, but the whole point of the pagination and the SQL LIMIT is for getting and displaying only what you need. |
|
Back to top |
|
stot Smarty Rookie
Joined: 13 Nov 2006 Posts: 17
|
Posted: Sun Dec 06, 2009 1:27 am Post subject: pagination internal data structures |
|
|
mohrt wrote: | You should only pass the data that is for display (the current page). Maybe I don't understand what you're trying to do, but the whole point of the pagination and the SQL LIMIT is for getting and displaying only what you need. |
Hi Mohrt,
thanks for your quick reply. I think, we talk at cross purposes.
What I mean is, that the pagination plugin calculates _all_ the page information with their number, start, end and current information as shown in the snippet in my last post. As the number of total results gets huge, also the calculation time of the pagination plugin increases. Additionally the full (and maybe huge) array will consume memory.
Maybe there is a solution to only calculate the page number, start, end, current information for those page links that are visible and clickable by the user.
Example:
total results: 30000
pages: 3000 / 10 results per page
Current page: 1
The pagination plugin calculates the page information (number, start, end, current) for all pages. The browser shows only the first page 10 links like:
page: 1 2 3 4 5 6 7 8 9 10 Next
The other page information from 11-3000 is not needed but calculated and stored in the $pagination->page array. My feeling was that the response time increased on big categories due to generating this huge array (with enabled Smarty Debug Console). The Size of the debug console showing the full array is around 1MB html code. On high traffic pages I would avoid calculating such huge datastructures, when I only need a small slice.
I hope I am not completely wrong on this track...
best regards
stot |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Dec 06, 2009 3:43 pm Post subject: |
|
|
I see. It should be pretty straight forward to implement, I'll take a look. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Dec 06, 2009 4:59 pm Post subject: |
|
|
Are you using the $paginate variable in the template, or are you just using the functions {paginate_middle} etc?
If you are not using the $paginate variable, you can just skip assigning it and you won't see this overhead. So:
SmartyPaginate::assign($smarty);
Leave the above expression out of your code and see what you get. |
|
Back to top |
|
stot Smarty Rookie
Joined: 13 Nov 2006 Posts: 17
|
Posted: Sun Dec 06, 2009 10:43 pm Post subject: performance measurements |
|
|
Hi Mohrt,
thanks again for your really quick reply.
I did some performance measurements (using apache ab) and compared requests/s with pagination of 30 hits to 30000 hits. The only difference in the testscript was the SmartyPaginate::setTotal( 30) call vs. SmartyPaginate::setTotal( 30000).
Results:
30 hits: ~20 requests/s
30000 hits: ~15 requests/s
I further compared the results above to the same test script without the SmartyPaginate::assign($smarty) call. There was no difference ;-( at all
Internally the paginate->page array is generated anyways by the plugin (although not assigned to smarty).
I think the performance loss is linear, so for 30000 hits you may loose 25% of requests/s. For 3000 hits you will only loose 2,5%. This is for most applications ok. I will figure out, if there is time to provide an optimized implementation.
The other settings I used:
debug: off
compile_check: false
caching=1
4000 requests in total
Anyways, I like smarty very much! keep up your good work.
best regards
stot |
|
Back to top |
|
hao Smarty n00b
Joined: 18 Dec 2009 Posts: 1
|
Posted: Fri Dec 18, 2009 8:40 am Post subject: Re: SmartyPaginate 1.6 released |
|
|
mohrt wrote: | Changes since 1.5:
* fix bug in paginate_middle, link not showing when item_total
= n*limit-1 (danw, monte)
* fix NOTICE messages in paginate_middle (Temas, monte)
|
this link is dead.
where can i get this plugin?! and SmartyPaginateRewrite is welcome
thanks
hao |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Fri Dec 18, 2009 3:00 pm Post subject: |
|
|
link is fixed. |
|
Back to top |
|
motohead2 Smarty n00b
Joined: 31 Mar 2010 Posts: 1
|
Posted: Wed Mar 31, 2010 9:33 pm Post subject: {paginate_middle format="page"} ??? |
|
|
Hello,
I am successfully utilizing the SmartyPaginate plugin.
I just had a quick question about {paginate_middle} function,
I would like for each page to be listed individually by using:
{paginate_middle format="page"}
prev [1] [2] [3] next end (something like that)
BUT, I'm not sure where to put that, or where to make the change.
Here is what I have right now (in my template file)
{paginate_prev} {paginate_middle format="page"} {paginate_next}
It made sense to me, but maybe I need to make the change somewhere else.
ALSO - My page is still showing the 'groupings' |
|
Back to top |
|
weblink Smarty Rookie
Joined: 03 Apr 2010 Posts: 12
|
Posted: Sat Apr 03, 2010 6:59 pm Post subject: How to do URL Encrypt with SmartPaginate? |
|
|
Hello,
I'm new to smarty and I've got problem with pagination when pass the data from one page to another. I need to encrypt the data while passing that one.
Here is my PHP code for setUrl....
Code: | SmartyPaginate::setUrl("http://localhost/virtual/getReport.php?open_date=".opendate."&close_date=".closedate."&virtual_id=".virtual_id); |
and the url displays the following Code:
Code: | http://localhost/virtual/getReport.php?open_date=05-02-2001&close_date=01-01-2009&virtual_id=5482&next=15 |
In this above program code, i need to encrypt or encode the Url value of opendate, closedate and virtual_id. hope this is enough information ...
Is it possible to do with SmartyPaginate?
thanks |
|
Back to top |
|
ileadu Smarty Rookie
Joined: 31 Aug 2006 Posts: 9
|
|
Back to top |
|
|