aspose file tools*
The moose likes Performance and the fly likes how to improve performance Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "how to improve performance" Watch "how to improve performance" New topic
Author

how to improve performance

k kousalya
Greenhorn

Joined: Jun 09, 2009
Posts: 12
hai ,

I have a doubt. I am doing small project. I have a large database in sql server. I have customer table which contains around million records. Customer table has 15 colums namely account_type,customer_id, Acctount_id etc. In my java program I have to get all records based on account type. For ex if account type is "savings", I have to get all the records of account type "savings" and need to do some other operation on those records. What i did was I created an ArrayList and store all the customer ids based on account type. and in if loop i am checking that the customer id is existed in that array list or not.It is working fine. But it is very slow. I want to improve performace as I have a large database.
Could you any one please give me a suggestion. thanks in advance.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

k kousalya wrote:I have to get all the records of account type "savings" and need to do some other operation on those records.

Now optimization is depends upon those "some other" operations also, fetching hundreds rows first, doing some operations on them, and showing them to user, will definitely improve the user experience as well as Java code execution.
As far as database is concerned, you need to have a proper indexing, so that data retrieval is fast.
k kousalya wrote: What i did was I created an ArrayList and store all the customer ids based on account type. and in if loop i am checking that the customer id is existed in that array list or not.It is working fine. But it is very slow.

Same here, no need to take all the Customer Ids in arraylist, take some rows at a time, also filtered out the required ids in the query itself which reduces the if conditions..

And welcome to JR


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
k kousalya
Greenhorn

Joined: Jun 09, 2009
Posts: 12
thank you
k kousalya
Greenhorn

Joined: Jun 09, 2009
Posts: 12
Actually I have to get all the records in my table based on account type. And I need to store these values into another file. Getting all the records from first table and storing those records in second table is costlier. Thats y , what i did was, first i am storing all the customer-id based on account type into an array list. Inorder to add those recors into second table i am using this array list. I am reading the records from the record and If the customer id is presented in the array list am inserting that value into second table.
But still it is costier. So I need to improve the performance. Please help me

thnak you sagar.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

k kousalya wrote:. Thats y, ..... those recors,... costier. ... thnak

UseRealWords
k kousalya wrote: And I need to store these values into another file.

The problem can be solved within the database server, itself. Write down a procedure which SELECTS the rows you want to write down into a file, google for how to exports those records into a file.
Ramchandran Natesan
Greenhorn

Joined: Jun 09, 2009
Posts: 1
if you want query datas from one table and enter the output of the select query to another table can use query like this

"insert into table2 (ACCOUNTTYPE,ACCOUNTID) SELECT ACCOUNTTYPE,ACCOUNTID FROM table1" can use some where condition in select query part

This is working fine in mysql

Ramachandran
 
wood burning stoves
 
subject: how to improve performance