This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
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.
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..
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