Skip navigation.
 
mlRe: Best Way To Lookup From a Huge Table
FROM : Jens Alfke
DATE : Thu Mar 13 23:30:37 2008

On 13 Mar '08, at 2:11 PM, Karan Lyons wrote:

> The table itself is pretty simple: It's just two columns, one with 
> every zipcode in the US, and the other with the corresponding 
> weather code.


If the weather-codes are all as short as in your example, you could 
create a file that's just an on-disk flat array of weather-codes, 
indexed by zip code. In other words, if a weather-code is at most n 
bytes long, you just seek to zipcode*n in the file and read n bytes.

Assuming n==8 as in your example, it would be an 800kbyte file. (But I 
bet it will compress really well, so it'll increase your app's 
download size by much less than that.)

—Jens

Related mailsAuthorDate
mlBest Way To Lookup From a Huge Table Karan Lyons Mar 13, 22:11
mlRe: Best Way To Lookup From a Huge Table John Stiles Mar 13, 22:27
mlRe: Best Way To Lookup From a Huge Table Jens Alfke Mar 13, 23:30
mlRe: Best Way To Lookup From a Huge Table Chris Hanson Mar 15, 01:31
mlRe: Best Way To Lookup From a Huge Table John Stiles Mar 15, 01:55
mlRe: Best Way To Lookup From a Huge Table Chris Hanson Mar 15, 02:15
mlRe: Best Way To Lookup From a Huge Table Ben Trumbull Mar 15, 02:39
mlRe: Best Way To Lookup From a Huge Table Scott Ribe Mar 15, 03:35
mlRe: Best Way To Lookup From a Huge Table Paul Thomas Mar 16, 10:19
mlRe: Best Way To Lookup From a Huge Table John Stiles Mar 17, 01:26
mlRe: Best Way To Lookup From a Huge Table Thomas Davie Mar 17, 17:31
mlRe: Best Way To Lookup From a Huge Table James Hober Mar 17, 19:38
mlRe: Best Way To Lookup From a Huge Table Scott Ribe Mar 19, 01:22
mlRe: Best Way To Lookup From a Huge Table E. Wing Mar 21, 00:58
mlRe: Best Way To Lookup From a Huge Table Michael Ash Mar 21, 05:48
mlRe: Best Way To Lookup From a Huge Table John Stiles Mar 21, 17:13
mlRe: Best Way To Lookup From a Huge Table Michael Ash Mar 21, 21:37
mlRe: Best Way To Lookup From a Huge Table John Stiles Mar 21, 21:51
mlRe: Best Way To Lookup From a Huge Table Michael Ash Mar 21, 22:03
mlRe: Best Way To Lookup From a Huge Table John Stiles Mar 21, 22:08
mlRe: Best Way To Lookup From a Huge Table Thomas Engelmeier Mar 22, 19:46