Avatar of Manikandan Thiagarajan
Manikandan ThiagarajanFlag for India

asked on 

search

if i have millions of record in to my db2 table.


How i would search effectively.


could you explain briefly
Java

Avatar of undefined
Last Comment
hoomanv
Avatar of Mayank S
Mayank S
Flag of India image

Perhaps this would be better explained in the data-base or DB2 topic-area (if there is one for DB2).

The best thing to do is create an index on the table for those columns on which searching is likely to be done (I'm not sure if DB2 supports creation of an index - I hope it does).
Avatar of Manikandan Thiagarajan

ASKER

is it needed to use collection interface? if yes, which collection i would implement
SOLUTION
Avatar of hoomanv
hoomanv
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of Mayank S
Mayank S
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
SOLUTION
Avatar of Mayank S
Mayank S
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
>>Meaning, say 20 at a time, or 50 at a time, in one quer

ok,i collect 50 records in one query., how coild i search in that query
Avatar of hoomanv
hoomanv
Flag of Canada image

> how coild i search in that query
linear search

not good for sreaching one million rows
Avatar of hoomanv
hoomanv
Flag of Canada image

why dont you use indexed tables ?

if you want to search in your own collected records, in an optimized way, try storing them in an structure like BTree or BinarySearchTree to improve the search speed
Avatar of Mayank S
Mayank S
Flag of India image

Nothing that you do on the Java side will affect the search performance on the DB side.
Avatar of Mayank S
Mayank S
Flag of India image

>> how coild i search in that query

The search on the DB side cannot be controlled by Java. It will search based on the indices, etc it has. Once you have the records in a result-set/ cached-row set, you can scroll through them.
>>an structure like BTree or BinarySearchTree to improve the search speed

could you explain that  one
Avatar of hoomanv
hoomanv
Flag of Canada image

an index in DB is implemented as BTree itself, no need to implement it yourself in your java app

http://en.wikipedia.org/wiki/Binary_search_tree
http://en.wikipedia.org/wiki/B-tree
ASKER CERTIFIED SOLUTION
Avatar of hoomanv
hoomanv
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Java
Java

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo