> Unfortunately I can't use such design because in this case I will not
> able to find in the database such data as I need

Yes, you will be able to find information you need. You can store your
data like this:

 time  |  val_num  |  value  |
--------|-----------|-----------|
[time_1]   1   [value_1.1]
[time_1]   2   [value_2.1]
 ...
[time_1] XXXX [value_XXXX.1]
[time_2]   1   [value_1.2]
[time_2]   2   [value_2.2]
 ...
[time_2] XXXX [value_XXXX.2]
[time_3]   1   [value_1.3]
[time_3]   2   [value_2.3]
 ...
[time_3] XXXX [value_XXXX.3]

Then your select will look like this:

SELECT ...
FROM table_name t1, table_name t2, table_name t456, table_name t654
WHERE t1.time > 1000 AND t1.time < 1500
AND t1.time = t2.time
AND t1.time = t456.time
AND t1.time = t654.time
AND t1.val_num = 1
AND t2.val_num = 2
AND t456.val_num = 456
AND t654.val_num = 654
AND (t1.value > t2.value + 3 OR t456.value != t654.value)


It looks like it's more complicated but I believe it will work faster
than your multi-column approach.


Pavel

On Sat, Sep 19, 2009 at 1:18 AM, Konishchev Dmitry <konishc...@gmail.com> wrote:
>> It'll work, but SQLite does not use a balanced tree to store the
>> columns for a particular record.  So if you're seeking the 700th
>> column of a particular row, it has to look through 699 others before
>> it gets to it.  Unless you always handle all the columns of a row
>> together, it'll be slow.
> Thanks for this information, it is helpful for me.
>
>> Because of speed, and the difficulty of correctly handling such a long
>> INSERT line, it's usually better to break this down into properties.
>> So instead of
>>
>> ID      prop1   prop2   prop3   prop4
>> --      -----   -----   -----   -----
>> 1       rec1p1  rec1p2  rec1p3  rec1p4
>> 2       rec2p1  rec2p2  rec2p3  rec1p4
>>
>> Do
>>
>> ID      propNumber      propValue
>> --      ----------      ---------
>> 1       1               rec1p1
>> 1       2               rec1p2
>> 1       3               rec1p3
>> 1       4               rec1p4
>> 2       1               rec2p1
>> 2       2               rec2p2
>> 2       3               rec2p3
>> 2       4               rec2p4
> Unfortunately I can't use such design because in this case I will not
> able to find in the database such data as I need (I described problems
> with which I faced in
> http://www.mail-archive.com/sqlite-users@sqlite.org/msg46229.html).
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to