473,383 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Fastest String search

Hi All,

I have to query the database with the string from text file. Here are
the details:

OS: WinXP Home Pro
DB: Oracle 9.x

The table in DB has 20,000 rows. The text file has 15,000 rows. I wrote
a program and read the string from text file and run SELECT query in DB
to look for the string. The program read line by line. That mean, For
each line the SELECT query is running, i.e. 15,000 times.

I use Streamreader class to read the text file and OracleDataReader
class to query the database.

Can anyone suggest me the better approach or design?

Thanks & Regards,
BeerSa

Dec 1 '06 #1
5 2149
I don't think there are enough details in the message to know.

Are you doing this one time? Once a day?

Do the contents of the text file change? Are more lines appended to it or
do you get an entirely new file?

Does it contain words or phrases? Are you looking for exact matches or
substring searches?

Can you import the text file into a table and perform a SQL query against
the table?

What do you need out of the process? Another text file, a report, an
updated DB?

And finally, is there a business requirement that limits the amount of time
it can take and/or the format of the DB and text files?
"beersa" <sa***********@gmail.comwrote in message
news:11**********************@n67g2000cwd.googlegr oups.com...
Hi All,

I have to query the database with the string from text file. Here are
the details:

OS: WinXP Home Pro
DB: Oracle 9.x

The table in DB has 20,000 rows. The text file has 15,000 rows. I wrote
a program and read the string from text file and run SELECT query in DB
to look for the string. The program read line by line. That mean, For
each line the SELECT query is running, i.e. 15,000 times.

I use Streamreader class to read the text file and OracleDataReader
class to query the database.

Can anyone suggest me the better approach or design?

Thanks & Regards,
BeerSa

Dec 1 '06 #2
Thanks Tom for your prompt response.

I would like to give you more details on this.
Are you doing this one time? Once a day?
Few times only. For some data mapping tasks.
Do the contents of the text file change? Are more lines appended to it or
do you get an entirely new file?
The text file is fixed-size word length and it is entirely new file.
Does it contain words or phrases? Are you looking for exact matches or
substring searches?
It is fixed size words. Looking for exact matches in database. So, the
search string from the text file.
Can you import the text file into a table and perform a SQL query against
the table?
What do you need out of the process? Another text file, a report, an
updated DB?
Output is text file.
And finally, is there a business requirement that limits the amount of time
it can take and/or the format of the DB and text files?
There is no Business requirements .

Hope you can assist me.

Regards,
Sabeer

Dec 1 '06 #3
Thanks Tom for your prompt response.

I would like to give you more details on this.
Are you doing this one time? Once a day?
Few times only. For some data mapping tasks.
Do the contents of the text file change? Are more lines appended to it or
do you get an entirely new file?
The text file is fixed-size word length and it is entirely new file.
Does it contain words or phrases? Are you looking for exact matches or
substring searches?
It is fixed size words. Looking for exact matches in database. So, the
search string from the text file.
Can you import the text file into a table and perform a SQL query against
the table?
What do you need out of the process? Another text file, a report, an
updated DB?
Output is text file.
And finally, is there a business requirement that limits the amount of time
it can take and/or the format of the DB and text files?
There is no Business requirements .

Hope you can assist me.

Regards,
BeerSa

Dec 1 '06 #4
If you only need to do it a couple of times and you the DB table is words
I'd tend to import each (if there are a few) of the text files into their
own DB table. At that point you should be able to run a single SQL Select
to match them up.

If you only had to run it once and you had no other way I'd say just process
it the way you have it and if it took a few hours it wouldn't be the end of
the world. On the other hand if you can save 50% of the time (or more) by
importing the file first and that amounts to 30 minutes or more I'd make the
extra effort.
"beersa" <sa***********@gmail.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.com...
Thanks Tom for your prompt response.

I would like to give you more details on this.
>Are you doing this one time? Once a day?
Few times only. For some data mapping tasks.
>Do the contents of the text file change? Are more lines appended to it
or
do you get an entirely new file?
The text file is fixed-size word length and it is entirely new file.
>Does it contain words or phrases? Are you looking for exact matches or
substring searches?
It is fixed size words. Looking for exact matches in database. So, the
search string from the text file.
>Can you import the text file into a table and perform a SQL query against
the table?

>What do you need out of the process? Another text file, a report, an
updated DB?
Output is text file.
>And finally, is there a business requirement that limits the amount of
time
it can take and/or the format of the DB and text files?
There is no Business requirements .

Hope you can assist me.

Regards,
Sabeer

Dec 1 '06 #5
beersa wrote:
Hi All,

I have to query the database with the string from text file. Here are
the details:

OS: WinXP Home Pro
DB: Oracle 9.x

The table in DB has 20,000 rows. The text file has 15,000 rows. I wrote
a program and read the string from text file and run SELECT query in DB
to look for the string. The program read line by line. That mean, For
each line the SELECT query is running, i.e. 15,000 times.

I use Streamreader class to read the text file and OracleDataReader
class to query the database.

Can anyone suggest me the better approach or design?

Thanks & Regards,
BeerSa
Beersa, at the risk of starting a barrage of complaints regarding
Portability/Compatibility and cries of "It's just not done that way",
have you ever thought of Rolling Your Own? By this I mean writing your
own Binary File Access method and reading the Oracle database records
without using any database engine.

If you're looking for speed then nothing will beat it!

I've often done this for clients who want VERY, VERY fast access to
information embedded in large databases. Using this type of method will
open the opportunity of reading, and scanning, tens-of-thousands of
records per second and locating the text you require faster than
anything you've probably ever seen before.

Just my thoughts.... You did ask for the "Fastest String Search"!!!

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Dec 1 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Simon | last post by:
Hi, If I have a string, (variable len), and I am looking for the first position of one char in array starting from position 'x' For example, // the 'haystack' $string = "PHP is great,...
2
by: tommazzo | last post by:
Hi! I'm looking for a way to find the position of a certain pattern within a string. On my search on the internet I've come accross various algorithms such as Knuth-Morris-Pratt and Boyer-Moore...
6
by: Jonathan | last post by:
I am hoping that someone more experienced than myself can point me towards what might be the fastest data lookup method to use for storing ip addresses. My situation is that I will need to maintain...
11
by: Ignacio X. Domínguez | last post by:
Hi. I'm developing a desktop application that needs to store some data in a local file. Let's say for example that I want to have an address book with names and phone numbers in a file. I would...
60
by: Julie | last post by:
What is the *fastest* way in .NET to search large on-disk text files (100+ MB) for a given string. The files are unindexed and unsorted, and for the purposes of my immediate requirements, can't...
12
by: Vjay77 | last post by:
Hi, I haven't posted any problem in quite a while now, but I came to the point that I really need to ask for help. I need to create an application which will search through .txt log file and...
3
by: Harry Haller | last post by:
What is the fastest way to search a client-side database? I have about 60-65 kb of data downloaded to the client which is present in 3 dynamically created list boxes. The boxes are filled from 3...
1
by: Harry Haller | last post by:
What is the fastest way to search a client-side database? I have about 60-65 kb of data downloaded to the client which is present in 3 dynamically created list boxes. The boxes are filled from 3...
9
by: Clinto | last post by:
Hi, I am trying to find the fastest way to search a txt file for a particular string and return the line that contains the string. I have so for just used the most basic method. Initialized a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.