aspose file tools*
The moose likes JSP and the fly likes how to make my application run faster Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "how to make my application run faster" Watch "how to make my application run faster" New topic
Author

how to make my application run faster

Mahesh Pinnamaneni
Ranch Hand

Joined: Jul 02, 2004
Posts: 100
hello buddies,
i am using JSP and Oracle 9i to develop my application. i want to design a JSP page where it shouls get the data from oracle and print in the browser in a table(used <table>...</table> tags).in oracle table there are around 1000 records and i want to print all of them in the browser. i have created the jsp which has db connections and display the data, but it takes some 15 min to generate the page.what and which technology i need to do inorder to load my page faster.i have used tomcat 5.0 as webserver.
plz tell which are the best practices to generate pages like from DB.
plz guide me..
thanks and regards,
Mahesh
Ezra Simon
Greenhorn

Joined: Sep 18, 2004
Posts: 9
Hi,

First of all - you should understand how that time breaks down to different tasks. You have

1)getting the data from the database
2)compiling the data onto a jsp page
3)sending the data from the server to the client
4)rendering the html in the browser

As a former interface developer, I will comment on 3 and 4, and let others comment on the first two.

I hope this is for yourself and not for your users, because you may end up crashing some machines with that much data - and users do not like that. It is always a best practice to break information into digestable bits.

But assuming it must be this way we have to keep code at a minimum, and keep html structures simple.

NO TABLES! They are deprecated anyway, and it takes a browser extra time to output tables.

If you can just go with this...

ITEM - DATA,DATA,DATA<br>
ITEM - DATA,DATA,DATA<br>
ITEM - DATA,DATA,DATA<br>
ITEM - DATA,DATA,DATA<br>

Avoid images and anything nested (span within divs, or whatever. If you want to make it looks nice you will have to break it up into bits.

That's it really. I could comment on the jsp bit, but there are probably others more qualified.

Jon
----------------
Get Jobs on GoodNoodles
http://www.goodnoodles.com
[ October 04, 2004: Message edited by: Ezra Simon ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Yes, shoving hundreds or thousands of records at your users generally isn't a very useful thing to do. Investigate paging the records.



Ummm, no. They are not. Where do you hear that from?

Tables are still the best way to display tabular data. (They are however, oveused for layout where CSS would be more appropriate). Modern browsers have no problems renderring even complex tables as long as you do not nest too deeply (which usually is a sign that you are using tables incorrectly).

The 15 minute lag is most probably a network or database issue. The use of tables or nesting spans in the HTML is not going to add any appreciable time to that kind of lag.
[ October 04, 2004: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Manoj Gundawar
Ranch Hand

Joined: Nov 17, 2002
Posts: 169
If you are making DB connection every time JSP is requested, that operation might eat some time. Try using connection pooling, in which DB connections are already made and are used as requested.
[ October 04, 2004: Message edited by: Jmannu gundawar ]

Manoj<br />SCJP, SCJD, SCWCD, IBM WSAD.
Mahesh Pinnamaneni
Ranch Hand

Joined: Jul 02, 2004
Posts: 100
thanks for ur suggestions. but i am having one more doubt here. Ok now i am havig some 500 records in the resultset and i need not display all the 500 records in a single page , infact in multiple pages like first 100 in a page and next 100 in 2nd page like this.how can actually solve this.
thanks & regards,
Mahesh
Rajan Chinna
Ranch Hand

Joined: Jul 01, 2004
Posts: 320
Mahesh
you have to use paging for that....
you can search this forum there are number of discussions on this topic.
Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
use seperate class for connection
Malhar Barai
Author
Ranch Hand

Joined: Aug 17, 2001
Posts: 399
Hi,

For paging, you can do a search on this or you can use the Pager Taglib.

HTH


Malhar Barai
SOA & Java Book
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Ok, you have done the paging but you are still doing full table scan. isn't it??

actually, it is very unlikely to do full table scan when the table has thousands of record. please make sure your database is tunned perfactly, specifically indexing could be the issue. but again avoid full table scans because indexes don't help in full table scans and it results in performance lack.

and as aforementioned, use connection pooling instead of getting connection while having request.
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
For paging use the Iterator pattern.
I have used this & also got succeeded in this ..
Refer to
http://java.sun.com/blueprints/corej2eepatterns/Patterns/ValueListHandler.html
this is best as far as i know.

Any way this approach first collects all the data from the DB initially.
Else try creating indexes in the DB for faster data retrival.

Srini
[ October 05, 2004: Message edited by: srini vasan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
Originally posted by Malhar Barai:
Hi,

For paging, you can do a search on this or you can use the Pager Taglib.

HTH


better yet, use JSTL which is standardised.

But best of all, tune that SQL to allow for retrieving only a subset of the data and not get all thousand records for each page of 100.

A 15 minute delay on requesting a JSP like yours is a database issue.
Most likely there's a major problem with bad indices, possibly combined with connections not being closed (causing you to have to wait until they time out).
Combine that with a long time needed to collect and transmit to your application server the massive amount of data you request with each query and you're bound for disaster.


42
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
You are going to have to do some measuring to see where things are slow.

I'll make a guess though. A 1000 row table shouldn't take 15 minutes to render so I would guess the query is slow (you can test this by running the query outside of your program in some sql tool), or you are concatenating strings and causing object allocation and garbage collection to be time consuming.

For example if you have a 200,000 character string and concatenate a "<td>" to it then a new string would have to be allocated to include the 200,004 characters and all data would have to be copied into here and then the old string would have to be garbage collected. If this is done a lot it is obvious how slow this could be. If you used a StringBuffer and the append method you wouldn't have this problem. Of course all this is a guess on my part and you should monitor your code to see what is consuming all the time.


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Raja Chandar
Greenhorn

Joined: Aug 05, 2004
Posts: 6
use value list handler pattern for displaying records
ravuthakumar gopalakrishnan
Greenhorn

Joined: Jun 09, 2003
Posts: 11
Hi

i suggest you to tune the application in all the layers

1) SQL :

make sure you are using right Optimized scan
(index based or full scan that suits your need)

consider to use First N Row Optimization

2)
Model :
If it is possible implement dynamic caching


3)

Presentation:

Use compression before sending response to the client
(employ filter to that job)

If you have time explore each topic further
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861

i suggest you to tune the application in all the layers


Without performance measurements, developers will spend their time guessing where performance bottlenecks occur. Performance problems typically occur in a small percentage of overall code. Algorithm guru Donald Knuth estimated that 4% of application code accounts for 50% of the performance. With measurements, developers can quickly locate that 4% of the code and get the biggest bang for their tuning buck. Without measurements developers waste effort tuning code that may have no significant impact on performance.
ravuthakumar gopalakrishnan
Greenhorn

Joined: Jun 09, 2003
Posts: 11
yes i agree with steve souza
Always eye on ROI.


-----
Sun Certified Programmer
Mahesh Pinnamaneni
Ranch Hand

Joined: Jul 02, 2004
Posts: 100
thanks alot guys for ur valuable suggestions. it really improved that damn performance.now i can generate the jsp within seconds.i have to thankful to one and all who have contributed their info to this article.
regards,
Mahesh
Manoj Gundawar
Ranch Hand

Joined: Nov 17, 2002
Posts: 169
Mahesh,
What was causing performance bottleneck in your appliaction? What did you fianlly do to improve it? Could you please give some details?
[ October 07, 2004: Message edited by: Jmannu gundawar ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to make my application run faster