Re: [sqlite] Can the Explain explain what is going on here?

2017-01-04 Thread Domonic Tom
Thanks Simon. I solved the issue by making sqlite3 *dbhandle = NULL then testing it for a null value afterwards. It works fine. From: sqlite-users on behalf of Simon Slavin Sent:

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Bart Smissaert
Have recompiled and indeed this makes both statements run at the same fast speed. I can also see that the both Explain now produce near enough the same. So it looks this has fixed it. I can see now that this could affect query speed not only in unrealistic testing situations, so this looks a

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Bart Smissaert
Thanks, will try that out. RBS On Wed, Jan 4, 2017 at 1:09 AM, Richard Hipp wrote: > On 1/3/17, Richard Hipp wrote: > > On 1/3/17, Richard Hipp wrote: > >> On 1/3/17, Bart Smissaert wrote: > >>> > >>> Firstly, is

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Bart Smissaert
All these UDF's are registered like this: RegisterUDF = sqlite3_create_function_v2(ByVal lDBHdl, _ ByVal cConn.UTF8BytesPointerFromUTF16String(strFunctionName), _ ByVal lArgCount, _

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Richard Hipp
On 1/3/17, Richard Hipp wrote: > On 1/3/17, Richard Hipp wrote: >> On 1/3/17, Bart Smissaert wrote: >>> >>> Firstly, is this a bug? >> >> No. A "bug" means it gets the wrong answer. In this case, it gets >> the correct answer, just

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Richard Hipp
On 1/3/17, Richard Hipp wrote: > On 1/3/17, Bart Smissaert wrote: >> >> Firstly, is this a bug? > > No. A "bug" means it gets the wrong answer. In this case, it gets > the correct answer, just more slowly than you would like. That means > this is an

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Keith Medcalf
On Tuesday, 3 January, 2017 17:18. Simon Slavin wrote: > On 4 Jan 2017, at 12:09am, Bart Smissaert > wrote: > > > Secondly, can the Explain statement tell me that indeed the UDF runs > 10 > > times in the first SQL and only once for the

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Bart Smissaert
I have checked and my presumed explanation was indeed correct. Runs 10 times (+ a few more for Prepare and check SQL etc.) with the first SQL and only a few with the second SQL. RBS On Wed, Jan 4, 2017 at 12:17 AM, Simon Slavin wrote: > > On 4 Jan 2017, at 12:09am,

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Bart Smissaert
Thanks for that. Yes, indeed not a bug. Not sure there is a scenario imaginable where this optimization will be helpful in real practice. RBS On Wed, Jan 4, 2017 at 12:25 AM, Richard Hipp wrote: > On 1/3/17, Bart Smissaert wrote: > > > > Firstly, is

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Richard Hipp
On 1/3/17, Bart Smissaert wrote: > > Firstly, is this a bug? No. A "bug" means it gets the wrong answer. In this case, it gets the correct answer, just more slowly than you would like. That means this is an optimization opportunity. Thanks for bringing it to my

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Bart Smissaert
> What makes you think that this is the case ? I didn't check, but this was the only explanation I could think of. Will check in a bit. RBS On Wed, Jan 4, 2017 at 12:17 AM, Simon Slavin wrote: > > On 4 Jan 2017, at 12:09am, Bart Smissaert >

Re: [sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Simon Slavin
On 4 Jan 2017, at 12:09am, Bart Smissaert wrote: > Secondly, can the Explain statement tell me that indeed the UDF runs 10 > times in the first SQL and only once for the second SQL? What makes you think that this is the case ? Why would SQLite not be running the

[sqlite] Can the Explain explain what is going on here?

2017-01-03 Thread Bart Smissaert
Have a table (only used for testing) like this: CREATE TABLE Table1([Field1] INTEGER) It has 10 rows and all the values in Field1 are 1. There are no indexes. Now I run queries that include a UDF. The code of this UDF is in VBScript and generally this is slow. This is the first SQL: