Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"

Ronald Djunaedi

+ Follow
since Jan 06, 2011
Ronald likes ...
Eclipse IDE Java Spring
DKI Jakarta, Indonesia
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ronald Djunaedi

g venkata wrote:I have three doubts in perofrmance fix
3. This is regarding JDBC and JSP using Oracle10g,Tomcat and JBOSS.Currently this is the scenario. I am retreiving more than 1000 records in resultset. But actually the user requires 10 records..rarely he requires 1000 records. Am iterating thru a loop in DAO class and getting that particular records in while(resultset,next()) and passing them to JSP (thru request obect)
If the user again requests for 20 again doing the same.
Because of this the query is executing again and again. and the server is becoming very slow.
(The code written long back and also not upto the standards and performance is not considered while developing)
But Now, i want to change it like..

for this thing, i have suggestion for you, get the records only in the exact what user needs, if they are needing 100 records, so only get the 100 records in the database level, you can use LIMIT for mysql, Rownum for ORACLE and so on.

If you only need 100 records, why would you fetch 1000 records ? the rest 900 will be useless and big enemy in performance.

8 years ago

Mike Simmons wrote:The most common cause for this sort of problem is failure to close the stream. So, are you absolutely sure that the stream was closed? What if an exception was thrown during the file reading - would you see it? Would the stream get closed regardless? (This is a good use for a "finally" block.)

Also - are you sure there aren't any other streams using the file? Reading or writing? If there are, make sure they're closed as well.

If you've checked this and are sure everything is closed, I don't know. There may be a defect in the filesystem - or in the Java implementation of file I/O activities. Depending on your perspective. Try inserting a short pause (e.g. with Thread.sleep()) in the program before you try to rename - does it make a difference?

Im quite agree with Mike, make sure to put all closing event in the finally block, to make sure they will be executed...
8 years ago
Hi Dorota, i hope you dont mind to post a full exception output, since it's hard enough to identify the problem only with the code you posted here...

Jan Cumps wrote:Welcome to the Ranch, Ronald.

Thanks Jan
im agree with most of the posts in here,
Changing your table will be the fastest way, add the timestamp column, so everytime you want to get 100 last inserted just do the query

Select top 100 * from my_table order by my_timestamp DESC

in the Sql Server,for others, will be similar though not in the exact same shape...