• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarifications on session attribute

 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

For Pagination, I am supposed to follow this approach:

Client requests page 1
Execute query
Cache complete result set
Return rows for page 1
Client requests page 2
Get rows from the cache and return rows for page 2

For caching the result set i am planning to use session attribute.
I need some clarifications:
1. If i store 20000 records in the session attribute, will it degrade the performance?
2. Is there any way to cache result set with out using session attribute.

Thanks
Sudha

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excess memory usage is pointless. Only fetch the number of rows that you are actually going to show. Fetching all 20000 in oder to show 16 is not a goof approach.
 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently i am using pagination on the DB side using rownum getting the desired number of records.
The new requirement is that I am supposed to get the entire information only once from the database and cache, when ever client requests it get the information from the cache. I am really not happy to use sessions but i dont know what to do.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Fetching all 20000 in oder to show 16 is not a goof approach.

Your Freudian slip is showing.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right! It is a "goof" approach! ;)

Seriously, that's a poor requirement -- I'd push back on it from a technical standpoint.

How many users are going to use the app? 10? 100? 1000? 1000000? Do the math.
 
sudha swami
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
20.. Each record has 2 clobs.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, do the math. Multiply how many simultaneous users you will have, times the size of the data held in the session.

Does it make sense to hold that much data in memory, most of which will never be viewed?
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, do the math. Multiply how many simultaneous users you will have, times the size of the data held in the session.


You could also do a load test to try to figure out how this will affect the app. That should answer your performance question.

2. Is there any way to cache result set with out using session attribute.


The easiest way to do it would be to use the session attribute. There are other ways that might reduce the cost of RAM usage but reduce performance also.

I am really not happy to use sessions but i dont know what to do.


Why do you have this concern ?

We have a couple of links here related to pagination

Javaranch tips on pagination
Pagination article

Hope that helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic