473,416 Members | 1,828 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,416 software developers and data experts.

What is the fastest way to search a (javascript) database?

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. strManager = "Adele Brown|Albert Meinstein|Alicia Perkins ..."

The first defect of the search is that it won't look for items
beginning with an umlaut etc.

The second defect is that it's far too slow.

The current page uses a regular expression search on the whole string
(it was taken from the O'Reilly regular expression book. Entering, for
instance, a 'b' in the search box results in the corresponding list
box showing ONLY those items beginning with a 'b' or 'B'. Likewise
entering 'Ba' narrows the search down even further. Unfortunately the
first letter search takes too much time.

What data structure is best used for holding the data for this search?

What is the best algorithm to use for such a search.

Should I construct a BST (binary-search-tree) on the server using the
IDs of the actual data items (with left and right pointers) - created
using Javascript arrays? With such a structure would a binary search
(BST) algorithm give me the fastest search?

OR, are BSTs normally constructed when data is being dynamically
added? All my data is static - the user only searches. In this case
do I simply need to order the data alphabetically and use a binary
chop to search it? PS: a typical search will need to select all items
beginning with a particular letter. Given that this will be the MAIN
search performed should I just create a second, 26 item, array
containing pointers to each first letter in my main array?

PS 1: For those, in news:alt.comp.programming, who don't know
Javascript has no pointers but supports arrays and associative arrays.

PS 2: in the server database all these names have IDs (but the
previous developer didn't download them to the client (to "save
space") - which explains the strManager above.

apologies to news:comp.lang.javascript for the duplicate post.
Oct 30 '06 #1
1 2404

Harry Haller wrote:
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. strManager = "Adele Brown|Albert Meinstein|Alicia Perkins ..."

The first defect of the search is that it won't look for items
beginning with an umlaut etc.

The second defect is that it's far too slow.

The current page uses a regular expression search on the whole string
(it was taken from the O'Reilly regular expression book. Entering, for
instance, a 'b' in the search box results in the corresponding list
box showing ONLY those items beginning with a 'b' or 'B'. Likewise
entering 'Ba' narrows the search down even further. Unfortunately the
first letter search takes too much time.

What data structure is best used for holding the data for this search?

What is the best algorithm to use for such a search.

Should I construct a BST (binary-search-tree) on the server using the
IDs of the actual data items (with left and right pointers) - created
using Javascript arrays? With such a structure would a binary search
(BST) algorithm give me the fastest search?

OR, are BSTs normally constructed when data is being dynamically
added? All my data is static - the user only searches. In this case
do I simply need to order the data alphabetically and use a binary
chop to search it? PS: a typical search will need to select all items
beginning with a particular letter. Given that this will be the MAIN
search performed should I just create a second, 26 item, array
containing pointers to each first letter in my main array?

PS 1: For those, in news:alt.comp.programming, who don't know
Javascript has no pointers but supports arrays and associative arrays.

PS 2: in the server database all these names have IDs (but the
previous developer didn't download them to the client (to "save
space") - which explains the strManager above.

apologies to news:comp.lang.javascript for the duplicate post.
Use hashes - they are very fast and handy. Much faster than search in
string and you can use umlauts etc. Ask me if you don't know how to use
hashes (and describe what kind of search users may perform).

Val Polyakh
http://trickyscripter.com

Oct 30 '06 #2

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

Similar topics

52
by: Tony Marston | last post by:
Several months ago I started a thread with the title "What is/is not considered to be good OO programming" which started a long and interesting discussion. I have condensed the arguments into a...
1
by: D. Lee Christopher | last post by:
Can anyone point me to a good tutorial for creating a site-level search applet? I am trying to create a virtual catalog of sorts, and I would like to be able to search the catalog and have the...
2
by: Zambo via SQLMonster.com | last post by:
Hi! We have Sql Server 2000 in our server (NT 4). Our database have now about +350.000 rows with information of images. Table have lot of columns including information about image name, keywords,...
6
by: richard.pasco | last post by:
Hey all I am trying to write a script that allows users to search through a database of names. But rather than give a search string and then return all those that match, I would like it to...
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...
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...
5
by: beersa | last post by:
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...
3
by: bluez | last post by:
I want to design a webpage where user can search the data from the database and list out the related records. Each of the record got a delete button which allow user to delete the record. ...
21
by: Pieter | last post by:
Hi, I need some type of array/list/... In which I can store objects together with a unique key. The most important thing is performance: I will need to do the whole time searches in the list of...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.