开发者

Is it suitable to perform Join Operations in Java, on a small sets of data retrieved from the database [duplicate]

开发者 https://www.devze.com 2023-02-07 13:37 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicate: Performing Join Operation in Java, on a small sets of data retrieved from the database. (context: web applica
This question already has answers here: Closed 12 years ago.

Possible Duplicate:

Performing Join Operation in Java, on a small sets of data retrieved from the database. (context: web application)

In context of a high traffic web application/ website, Is it suitable to do some JOIN operation in Java, on the data retrieved from the database(from first query), and use that "JOIN"ed data for the second and final query to the database to get the required data ?

(I know, this is not the best thing to do, but the database is not a SQL database & does not allow for JOIN operations.)

The data for the JOIN operation is: - One dataset contains about 50 integers(avg) and other contains about 150 integer开发者_如何学Gos(avg).

The 1st dataset would have list of only integers but the second will have a list of sets of integer & a 'data-integer'. If the two integers in the two datasets intersect then the corresponding 'data-integer' is passed in the results list. So the result would contain the data integers corresponding to the intersected integers.

For e.g.

List A ={ 21, 65, 93}

List B ={ (21, 42342), (53,73242), (93, 32312)}

Result ={ 42342, 32312 }

Both of the two sets data for the JOIN operation may be implemented in the form of a tree structure. Hence this JOIN operation could be made more efficient because only trees will need to be compared not the entire list (While performing JOIN, if the two (similar depth) nodes do not match at some node in the tree, then all its child nodes will be skipped, and the control will move to the next top node)

Thanks.


You can create a Map<Integer,Integer>

where the key is "join" column (either table A Integer value or table B first value of the set) and the value ןs Table B second value of the set. Enter the query results to the map. This way you will be able to get the "join" results from the Map

Hope this helps

0

精彩评论

暂无评论...
验证码 换一张
取 消