Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.databases > #509

Searching for ranges

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.databases
Subject Searching for ranges
Date 2011-11-21 08:56 -0800
Organization Canadian Mind Products
Message-ID <nqukc7ta1mrd128h8tqbabo9k9e76eq7ak@4ax.com> (permalink)

Show all headers | View raw


I was wondering about techniques for using SQL to find records with a
low-high associated range, especially when the ranges are contiguous,
or when the range sizes are a multiple of some integer.

I am familiar with in-RAM technique such as binary search and dividing
by the range size/atomicity to get an index.

I suspect just asking
for  table.low <= wanted < table.high
won't be that clever, even if low and high are indexed.

I wondered if there were standard solutions to the problem.

The pattern of cases defined by bounds, particularly when the bounds
are contiguous comes up quite frequently.  I am surprised there are
not more built in features in languages, Collections and databases to
efficiently handle it.

Some places where this band-searching problem comes up:

converting a random number 0 <= r < 1  to select a weighted quotation.

deciding which unit of measure to use depending on its size.

deciding which rule to use for inserting dashes in a ISBN depending on
is band.

naming colours

clipregion bands

converting frequency to RGB

UTF-8 encoding

converting weight, height etc to evaluation words.

calculations with coins.

displaying a wide range of numbers or currency values.

-- 
Roedy Green Canadian Mind Products
http://mindprod.com
I can't come to bed just yet. Somebody is wrong on the Internet. 

Back to comp.lang.java.databases | Previous | NextNext in thread | Find similar


Thread

Searching for ranges Roedy Green <see_website@mindprod.com.invalid> - 2011-11-21 08:56 -0800
  Re: Searching for ranges Martin Gregorie <martin@address-in-sig.invalid> - 2011-11-21 21:18 +0000
  Re: Searching for ranges David Lee Lambert <davidl@lmert.com> - 2012-01-17 11:59 -0800
    Re: Searching for ranges Roedy Green <see_website@mindprod.com.invalid> - 2012-01-19 09:32 -0800

csiph-web