[sqlite] Index on computed value?

2015-12-16 Thread Dan Kennedy
On 12/16/2015 03:17 PM, Deon Brewis wrote:
> Is it possible to have an index on a computer value?
>
>
> E.g. I have a 40 byte value in one of my columns. I only want an index over 
> the first 4 bytes of it.
>
>
> However, I don't really want to repeat those 4 bytes inside another column on 
> the main table.
>
>
> Is there any way to accomplish that?

Something like

   CREATE TABLE t1(x BLOB);
   CREATE INDEX i1 ON t1( substr(x, 1, 4) );

   https://www.sqlite.org/expridx.html

Dan.



[sqlite] Index on computed value?

2015-12-16 Thread Zsbán Ambrus
On Wed, Dec 16, 2015 at 9:17 AM, Deon Brewis  wrote:
> Is it possible to have an index on a computer value?
>
> E.g. I have a 40 byte value in one of my columns. I only want an index over 
> the first 4 bytes of it.
>
> However, I don't really want to repeat those 4 bytes inside another column on 
> the main table.

See http://sqlite.org/expridx.html

Ambrus


[sqlite] Index on computed value?

2015-12-16 Thread Simon Slavin

On 16 Dec 2015, at 4:23pm, Zsb?n Ambrus  wrote:

> See http://sqlite.org/expridx.html

"The ability to index expressions was added to SQLite with version 3.9.0 in 
October of 2015"

Nice to see that the development team's crystal ball is running around three 
months ahead of questions on this list.

Simon.


[sqlite] Index on computed value?

2015-12-16 Thread Deon Brewis
Is it possible to have an index on a computer value?


E.g. I have a 40 byte value in one of my columns. I only want an index over the 
first 4 bytes of it.


However, I don't really want to repeat those 4 bytes inside another column on 
the main table.


Is there any way to accomplish that?

- Deon