On 26 Feb 2012, at 4:06pm, Rita <rmorgan...@gmail.com> wrote:

> if I can have a primary key of t+user (which would be ideal) how can I do a
> search? Can I do a key partial key scan in sqlite? For instance, give me
> the record for user 'foo' from time 'x to y' ?

The technical answer to this is that you can search a table for any data in it. 
 Just phrase the 'WHERE' clause of your SELECT correctly and it's up to the SQL 
engine to figure out how best to do the search.  But it would be nice to know 
whether the search could be done efficiently, so ...

If you want to do searches for a specific user and a time range, then you will 
get fastest results if you have a key of (user, t) not (t, user).  This might 
be a better primary key.  Or you might want to keep your primary key as it is, 
and CREATE an INDEX for this order.

If you want to reason these things out, think of listing the data as if you 
were printing a telephone directory.  For the most efficient searches you want 
all the records you're looking for to appear in one continuous run.  So figure 
out an index order which will list them that way.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to