On 10/26/17, Wout Mertens <wout.mert...@gmail.com> 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 d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users