| [reply] |
One way to do it is to use a database to store the results of the query (you could also use that to cache queries - faster for often repeated queries - if your database does not support that)
see this pseudocode:
- Get result of select distinct id from table where QUERY
- store the IDs (probably separated by commas, or another delimiterm as well as QUERY, and number of results in a database table);
- To display a page, split the delimited results and use an array slice and just query the database for the rest of the fields for the IDs in the current page (where id in (xx,yy,zz,...etc.) ).
This would only be good for small result sets... I don't even recommend showing search that has more than 10-20 pages ... I would probably display a message at the last page saying that there are a lot of results, and ask the user to narrow down the query. | [reply] |
Just a thought, Why not do the select * ONCE and save all records into either a temp file or a Hash etc... Only display what was asked for. ie 1-10 or 11-20.. then have another linmk that could re-run the query should that be necessary..?(possible fast and plenty updates/inserts)
-----
Of all the things I've lost in my life, its my mind I miss the most.
| [reply] |
Data::Page and PageSet modules are for the list of values that
we have in our hand(variables), that is not what I want. I wanted to eliminate the long processing time which takes during query execution by cutting off with limit but still be able to get the total no of count any time.
having a select * ONCE and save it into hashes also rulled out for two reasons
* the queries will be dynamic (same query may not come for service next time)
* if the query is going to return say 20000 records, imagine the amount memory required to store them in RAM(it would be atleast in MBs) and perl will be smart enough not to release the memory even after the hash is destroyed, which would be used for future requests. This makes other system processes not getting the memory
Though I am currently using the second method only, i am rulling it out because of this memory usage problem and i want to use much better algorithm than this
Thanx anyway for replies,
Any further suggestions are welcomed
gopi
| [reply] |