On 10/26/17, Wout Mertens <[email protected]> wrote: > I have a table with an indexed json field, and I want to know the maximum > value of that field. > > create table events(id integer primary key, json JSON); > create index t on events(json_extract(json, '$.ts)); > > If I do > > select max(json_extract(json, '$.ts')) from events; > > it does a table scan with the index, > > Is this an optimization opportunity for calculated indexes?
It is. There is a min/max optimization to deal with this situation, but it currently does not know about indexes on expressions. -- D. Richard Hipp [email protected] _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

