On 4/14/08, Chris Tracy <[EMAIL PROTECTED]> wrote:
> >  If you need to do this from the shell, I'm not sure there is anything
>  >  you can do.  If you're doing this from the C API just look for timestamps
>  >  that are >= your target and terminate the query as soon as you find one
>  >  larger than the target timestamp (e.g. stop calling step() and call
>  >  reset() on the statement).  If the number of datapoints at a given
>  >  timestamp is known (because it is fixed, or because you stashed that
>  >  value in another table), you could also use a LIMIT clause.  That has
>  >  the added bonus of doing the right thing (even if it takes longer) if
>  >  the rows somehow get out-of-order.
>
>
>         I'm actually using Perl's DBI interface.  Not sure that I can
>  easily do the exit when seeing a timestamp one bigger than the one I'm
>  after, but it's an intriguing idea I'd not considered before.  The LIMIT
>  I'd also considered, but since the data is variable, I'd abandoned it.
>  Hadn't considered storing the value in another table.  But since the whole
>  thing was based on an invalid premise (that SQLite was somehow magically
>  finding the initial value quickly, ignoring that it just happened to be
>  closer to the start of the db) I think I'll take another approach to
>  solving the problem.
>

heck, I didn't realize you were using Perl (I thought you were working
in some highly constrained environment with 2 bytes of memory, like
the Mars rover or something).

Just exit the loop.

my $timestamp = 1167615600;
while ($ary_ref = $sth->fetch) {
  last if $ary_ref->[0] > $timestamp;

  do other stuff...
}

what's the problem? It should be blindingly fast.


>         Thanks for the input though,
>
>
>         Chris
>
> _______________________________________________
>  sqlite-users mailing list
>  [email protected]
>  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Puneet Kishor http://punkish.eidesis.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to