Re: [sqlite] Custom aggregate functions in Tcl

2019-02-02 Thread Andy Goth
I made many updates to my implementation, which can be found here: https://chiselapp.com/user/andy/repository/sqlite-andy/timeline?r=andygoth-tcl-function https://chiselapp.com/user/andy/repository/sqlite-andy/artifact?fn=src/tclsqlite.c=andygoth-tcl-function

Re: [sqlite] Min/Max and skip-scan optimizations

2019-02-02 Thread Simon Slavin
On 2 Feb 2019, at 10:19pm, Gerlando Falauto wrote: > SELECT source1, source2, ts, value > FROM rolling > WHERE source1 = 'aaa' > AND ts > 1 AND ts < 10; > > [...snip...] > So I add an extra ORDER BY clause: Concentrate on the results you want. Don't try to 'game' the library. You don't

Re: [sqlite] Min/Max and skip-scan optimizations

2019-02-02 Thread Keith Medcalf
Like this? SELECT rolling.source1, rolling.source2, ts, value FROM ( select distinct source1, source2 from rolling where source1 = 'aaa' ) as x JOIN rolling ON rolling.source1 = x.source1 AND

Re: [sqlite] Min/Max and skip-scan optimizations

2019-02-02 Thread Tim Streater
On 02 Feb 2019, at 22:19, Gerlando Falauto wrote: > What I'm now trying to do is filter on source1 and by range of timestamp. > Results should be naturally ordered by source1, source2,ts. Not unless you use an ORDER BY. -- Cheers -- Tim ___

Re: [sqlite] Min/Max and skip-scan optimizations

2019-02-02 Thread Gerlando Falauto
Hi, it's me again, struggling with indices once again. What I'm now trying to do is filter on source1 and by range of timestamp. Results should be naturally ordered by source1, source2,ts. 1) SELECT source1, source2, ts, value FROM rolling WHERE source1 = 'aaa' AND ts > 1 AND ts < 10; QUERY

Re: [sqlite] Min/Max and skip-scan optimizations

2019-02-02 Thread Simon Slavin
On 2 Feb 2019, at 10:19pm, Gerlando Falauto wrote: > Results should be naturally ordered by source1, source2,ts. [Sorry, I missed this the first time. Thanks, Tim.] Sorry, no. You're making assumptions about how SQLite works internally. If you want your results sorted, ask for them sorted.