I'm doing some comparisons with a bunch of SELECT statements that call the same (complex) stored function with different parameters, say something like
When using dbisqlc and DBISQL with v12.0.1.4178, I notice that sometimes all or nearly all of the function calls are skipped without any warning or the like. (They use MESSAGE statements to print out their actions, so I can track their calls). Why is that? I explicitly declared the stored function as NOT DETERMINISTIC (though I don't call it with identical arguments). MAX_QUERY_TASKS and MAX_PLANS_CACHED are on their default values, in case some kind of (unexpected) "intra-batch" parallelsm could apply here. May this be anyhow related to DBISQL's options w.r.t. the output of result sets from multiple statements / procedures with multiple result sets? - I have modified those options as following, and now all function calls are executed:
Before I had chosen the "Show results from the last statement" option, however, I would certainly not expect that "not showing a result set" would mean "not calling that statement"... EDIT: When I set back that option to "Show results from the first statement", all the function calls are skipped in DBISQL. So I guess that seems to be the problem's source... |
Let me start over with a few (better informed) observations about dbisqlc to see if that helps. It is actually not clear how you are measuring this. Are you watching the statements sent to the database server by reading the 'requestlogging' output? Or are you just watching the result set displayed? If you are looking at the request log, and if you are seeing statements getting skipped maybe you can post that to show us more detail about this. {from my tests I did not see that happening at all} DBISQLc when presented with multiple statements (separated by either ';' or '\ngo\n') will only ever display the last result set. To get multiple result sets to display you need to bracket those inside of BEGIN ... END; statements and issue RESUME operations for each 'next' result set you want to see. The RESUME statement works the same for WSQL procedures that return multiple results so packaging those statements up as a stored procedure will also allow you to step through the result sets using the RESUME statement. [The 'BEGIN' and 'END;' statements make the block of SQL in your script script a single SQL batch, which is the equivalent of an unnamed SQL procedure; so it is the same feature.] As you can see DBISQLc handles result sets in a very different way than the Java DBISQL utility does. And observed behaviours or features seen from using dbisql are not guaranteed to be available in dbisqlc {many will not be}. As to when the 2 started diverging, that is documented as starting in 9.0.x. As of the 9.0.2 doc set, the "Deploying administration tools" article started talking about this stating "....does not contain all the features of [the java DBISQL] and compatibility between the two is not guaranteed." ! And finally there has be non-GUI versions of dbisqlc and if you are running one of those (Unix and possibly Linux) the behavior of those may be slightly different again. Basically dbisqlc is provided to allow legacy DBA crafted scripts, legacy OEM scripts, and non-gui platforms have backward support available. Some additions do make it into dbisqlc (to allow for new data types for example) but you should consider it to be a dead-end component as far as new feature development goes. I hope something in here helps. Hm, just to provide more information (I'm out of office now...):
(07 Aug '15, 13:11)
Volker Barth
Replies hidden
Further tests reveal:
(10 Aug '15, 02:27)
Volker Barth
|
Hello Again Volker, Is possible you are just benefitting from "client side statement caching"? . . . and that all of the results are getting processed but you are just not seeing the PREPAREs you were expecting to see? If that is the case then just [temporarily] setting the option max_client_statements_cached=0 will cause them to show up again. With caching enabled (which is on by default) many of your statement PREPARES may not be showing up in the request log because those are not needed if the statement was found in the client-side cache. IE the PREPAREs are not getting logged as they have been replaced by various CACHED_DROP_STMT and VALIDATE_STMT entries instead. You may not seeing the same number of PREPARE entries but you should see the same number of OPEN operations. {testing with verbose logging reveals everything} HTH Hm, that option is set to its default, however, as the individual function calls all have different arguments. Given that and the explicit NOT DETERMINISTIC clause, I would think they should not be cached at all. - I will check that after the weekend...
(07 Aug '15, 13:15)
Volker Barth
Replies hidden
Further tests seem to reveal that client statement caching is not the problem here: Neither do the connection properties "ClientStmtCacheHits" and "ClientStmtCacheMisses" show relevant values nor does the behaviour change if I disable client statement caching by setting the max_client_statements_cached option to 0. (It's still my impression that the function-call statements are "silently" skipped, see my comments on the answer answer.) Just to clarify: Will client statement caching cache only statements with the exact SQL test (including the exact same arguments), or would it try to cache "SELECT myFunc(1)" and "SELECT myFunc(2)", too? - Note that when using DBISQL, I do not explicitly tell the client library whether I want to use a prepared statement or not...
(10 Aug '15, 02:37)
Volker Barth
I just got back from a short vacation and have noticed you have continued the discussion on another thread. Obviously the information there is interesting and shows a more subtle definition for this behavior. http://sqlanywhere-forum.sap.com/questions/25326/may-dbisql-skip-select-statements-in-a-sql-batch-part-ii
(17 Aug '15, 12:57)
Nick Elson S...
Replies hidden
Yep, according to Breck's advice, I created that new FAQ - see our discussion in the comments on the question itself...
(17 Aug '15, 15:25)
Volker Barth
|
Same answer in part II, but just in case: I have found that when I have multiple select statements that call functions that return results, I have to use a begin / end and select the results into a variable to get them all to execute. Your "SET myVar = test();" becomes my:
I had always suspected it was because DBISQL didn't have a way to handle the multiple result sets, but I never dug into it. Once I had this as the answer I used it and moved on. Note that I'm not storing myVar and I don't care to return its results. For my case I just needed it to be sure each procedure call executed. |
dbisqlc seems to be influenced by that option, as well, though it is not even visible/settable there AFAIK:
When DBISQL is set to "Results from the last statement", dbisqlc seems to execute just "some" of the SELECT statements, in my current case the first 16 (in one run) or the first 4 (in the next run) from around 50 calls. The following statements are normally executed. Very strange.
When DBISQL is set to "each statement", dbisqlc seems to behave as expected.That has been that way in one run, but after restarting dbisqlc, it again just executes some of the calls. Even stranger.Note: I'm aware that the actual reason may be related to a fully different issue, I'm just trying to get some clues...
Note, that problem is reproducible, so a restart (as suggested by Breck) won't help.
Though I prefer dbisqlc for timings (DBISQL does too much under the covers, AFAIK), I cannot use dbisqlc (neither 32-bit nor 64-bit) here, as the SQL batch is not executed reliably, and that makes the answer to my general question "Do both versions behave identically here?" quite hard to answer:(
FWIW: The same happens with v16.0.0.2158, too. I'm stuck.
Maybe it will help to know the function definition.
FWIW this is the second dbisqlc issue you have reported that others seem uncapable of reproducing. Not certain what can be causing these differences yet ... so any additional info. may prove valuable.
...and it also appears with dbisqlc v17.0.0.1062 - DBISQL runs fine here, possibly because it always displays all result sets of all statements, i.e. the option is gone.
Hm, it's a high-level function that basically runs a loop that calls several other complex functions within a savepoint - I guess that won't be helpful without the whole database schema...
The function header is as following:
The ISQL batch (note: without a BEGIN/END, so no code block) consists of some timing calculations and then a bunch of "select MyFctn(0, x);" calls. The console log shows that dbisqlc just executes some first n of these calls as the initial message statement for these other calls is not reported in the log.
That's good advice. My current problem is that the specific stored function and the underlying schema is way to complex to show here...
And I have been to lazy to try to figure out a simple reproducible but that's on my to-do list...
Tip: The first step in the reproducible should be dbinit :)
Sorry, I started with MD...
Here we ware.