aspose file tools*
The moose likes JDBC and the fly likes Comparing Temporary table with a huge database 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 » Databases » JDBC
Bookmark "Comparing Temporary table with a huge database" Watch "Comparing Temporary table with a huge database" New topic
Author

Comparing Temporary table with a huge database

Pradeep Kadambar
Ranch Hand

Joined: Oct 18, 2004
Posts: 148
In my program I create a temp table with few thousand records. I want to find the entries that are only in the temp table and not in the main table ; which is huge containing hald a million records.[id - name]

I did a inner join on the name value and then outer join on the result i.e Temp - (Temp intersection Main Table). The query executes in a fraction of a second but in the program the processing of result set is slow.

Any other solutions that can handle this situation.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Pradeep,
Since the query itself is executing quickly, the query is fine. What are you doing when processing the result set? Try looping through the result set in an empty loop to see if it is the network transfer or the loop body.

If the network tranfser, try returning less fields in the select clause. (This is actually a good idea anyway if there are unused fields.) If not, look into which statements in the loop body are taking the longest.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Pradeep Kadambar
Ranch Hand

Joined: Oct 18, 2004
Posts: 148
From the resultset I just take two field id and name and then create an object from it. If the file path (Which is one of the fields) is new then an insert statement is addd to batch and then executed.

If the resultset is empty the program executes faster.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Comparing Temporary table with a huge database