472,780 Members | 1,434 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 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 2349

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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.