473,698 Members | 2,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 OracleDataReade r
class to query the database.

Can anyone suggest me the better approach or design?

Thanks & Regards,
BeerSa

Dec 1 '06 #1
5 2175
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.goo glegroups.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 OracleDataReade r
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.goog legroups.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 OracleDataReade r
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
2541
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, php is ok"; // the needles
2
2664
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 (just to name two). But which is the fastest? Thanks already in advance!
6
5489
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 a list of perhaps 50 ip addresses to be used in a packet sniffing application. For each packet that goes through the application (which will be monitoring all traffic through a switch), I need to see if an entry for the source ip of that packet...
11
2110
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 like to be able to retrieve the name by searching for a given phone number the fastest I can. I have considered the posibility of using XmlTextReader with something like: <list> <item number="1234567"> <name>John Doe</name>
60
49101
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 be indexed/sorted. I don't want to load the entire file into physical memory, memory-mapped files are ok (and preferred). Speed/performance is a requirement -- the target is to locate the string in 10 seconds or less for a 100 MB file. The...
12
6442
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 find all lines where email from hotmail occured. All these emails need to be printed to list box on the form. Problem with code you'll see below, is that it takes long time to
3
1786
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 string arrays, which are just lists of people or companies in alphabetic order. These names may have accented and umlauted characters (which are present as the plain ASCII - not as the entity &# character). The page is UTF-8 encoded. e.g. ...
1
2427
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 string arrays, which are just lists of people or companies in alphabetic order. These names may have accented and umlauted characters (which are present as the plain ASCII - not as the entity &# character). The page is UTF-8 encoded. e.g. ...
9
6138
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 variable as IO.streamreader. Read each line and perform an if-then to see if var.contains(mystring) is true or false. if true I get my string if false it reads the next line. This takes for ever. Is there anything I can do to speed this up? Thanks.
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.