[sqlite] How to programmatically determine if trace is enabled for a db connection ?

2017-05-29 Thread Howard Kapustein
I can set a trace hook and I can clear a trace hook, but I don't see any way to tell if a sqlite3* has a trace hook registered If not then consider this a feature request :P e.g. int sqlite3_db_config(db, SQLITE_DBCONFIG_TRACE) returning an OR'd combination of SQLITE_TRACE_* as you'd set via sq

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread Simon Slavin
On 29 May 2017, at 5:48pm, Jeffrey Mattox wrote: > Why does a complex computation (but still consisting of only constants) make > a difference as to whether the computation is performed once or many times? > What's the dividing line between "simple" and "complex"? Your program has a task to

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread Richard Hipp
On 5/29/17, Jeffrey Mattox wrote: > Why does a complex computation (but still consisting of only constants) make > a difference as to whether the computation is performed once or many times? > What's the dividing line between "simple" and "complex"? The dividing line is the number of opcode need

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread Jeffrey Mattox
Why does a complex computation (but still consisting of only constants) make a difference as to whether the computation is performed once or many times? What's the dividing line between "simple" and "complex"? Jeff > On May 29, 2017, at 8:51 AM, Richard Hipp wrote: > > It is true that SQLit

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread x
I’m fairly sure the gains won’t be worth the effort RS as any arithmetic will mostly be in the WHERE clause. Thanks. From: R Smith Sent: 29 May 2017 15:18 To: sqlite-users@mailinglists.sqlite.org Subject: Re: [sqlite] Does p

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread R Smith
On 2017/05/29 4:05 PM, x wrote: Thanks Richard. I can’t claim to fully understand the part about the app calling sqlit3_column_text but I’m reassured that leaving the arithmetic to sqlite is the way to go. Actually what Richard is saying is that you SHOULD do the arithmetic yourself when yo

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread x
Thanks Richard. I can’t claim to fully understand the part about the app calling sqlit3_column_text but I’m reassured that leaving the arithmetic to sqlite is the way to go. From: Richard Hipp Sent: 29 May 2017 14:52 To: SQLite mailing list

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread Richard Hipp
On 5/29/17, x wrote: > Thanks Clemens, that clears that up. > > I’m still left wondering though why it calculates 2+2 every step in > > ‘select 2+2 from Tbl;’ > All result values must be recomputed on every step because the application can change the value by (for example) calling sqlite3_column_

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread Hick Gunter
The expression is calculated as given in each case. The difference being that a constant constraint is recognized in the query planner (and thus calculated once with the result being saved), whereas a constant expression as a return value is not. -Ursprüngliche Nachricht- Von: sqlite-us

Re: [sqlite] SELECT WHERE with RTREE and second condition slow

2017-05-29 Thread Thomas Flemming
Ok, here is a sample to try these queries: http://files.qvgps.com/0-tom-public/Geonames_World_2017.zip (825mb, 12 mio records) Before I change my app-logic to do the styleid-query on the app-side, I would like to know, if there might be a chance to get this fast on the sqlite-side. very fast

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread x
Thanks Clemens, that clears that up. I’m still left wondering though why it calculates 2+2 every step in ‘select 2+2 from Tbl;’ but only once in ‘select * from Tbl where Col=2+2;’ I’m writing code that makes certain changes to the SQL before it submits it to sqlite3_prepare. Initially I assum

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread Clemens Ladisch
x wrote: > The explain for > > Select * from Tbl where Col = (select min(OtherCol) from OtherTbl); > > I’m having problems with. EXPLAIN Select * from Tbl where Col = (select min(OtherCol) from OtherTbl); addr opcode p1p2p3p4 p5 comment -

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread x
Thanks for the reply Gunter. The reason I added “from Tbl” was so there would be more than 1 step involved. The explains require a fair knowledge of the opcodes for more complex queries so I’m still not totally sure as to the answer to my question. Assuming I’m reading the explains properly, th

Re: [sqlite] SELECT WHERE with RTREE and second condition slow

2017-05-29 Thread Thomas Flemming
Morning, > Does ANALYZE gather statistical data about rtree virtual tables? I seem to ANALYZE doesn't help. I'm busy preparing and uploading a sample-db, then it might be easier to figure that out. Tom Am 28.05.2017 um 11:01 schrieb Wolfgang Enzinger: Am Sat, 27 May 2017 19:20:00 -0400 schrie

Re: [sqlite] CLI option to NOT autocheckpoint WAL databases

2017-05-29 Thread Rowan Worth
On 29 May 2017 at 14:46, Clemens Ladisch wrote: > Howard Kapustein wrote: > > I'm effectively looking for a -readonly option, or how to achieve that > > net effect > > sqlite3 "file:test.db?mode=ro" > > But if you want to be really sure, set the file permissions to disallow > writes. (You have t

Re: [sqlite] Does prepare do arithmetic?

2017-05-29 Thread Hick Gunter
Try for yourself. .mode explain explain select 2 +2; explain select 4; BTW: The "from Tbl" clause will only affect the number of result rows (1 for every row in Tbl). -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von xTom B

[sqlite] Does prepare do arithmetic?

2017-05-29 Thread xTom Byars
Please satisfy a curiosity for me If I prepare Select 2 + 2 from Tbl; Will the prepared code be the same as Select 4 from Tbl; Or is the 2+2 calculated at every step? ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailingl