aspose file tools*
The moose likes JSP and the fly likes Clarifications on session attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Clarifications on session attribute" Watch "Clarifications on session attribute" New topic
Author

Clarifications on session attribute

sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
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

Joined: Jan 10, 2002
Posts: 61768
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sudha swami
Ranch Hand

Joined: Apr 24, 2007
Posts: 179
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jan 10, 2002
Posts: 61768
    
  67

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

Joined: Apr 24, 2007
Posts: 179
20.. Each record has 2 clobs.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61768
    
  67

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

Joined: Feb 24, 2006
Posts: 6662
    
    5

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


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Clarifications on session attribute