{"action":"created","issue":{"url":"https://api.github.com/repos/ttddyy/datasource-proxy/issues/19","labels_url":"https://api.github.com/repos/ttddyy/datasource-proxy/issues/19/labels{/name}","comments_url":"https://api.github.com/repos/ttddyy/datasource-proxy/issues/19/comments","events_url":"https://api.github.com/repos/ttddyy/datasource-proxy/issues/19/events","html_url":"https://github.com/ttddyy/datasource-proxy/issues/19","id":70849614,"number":19,"title":"Detecting static and prepared statements","user":{"login":"shahamit","id":1281926,"avatar_url":"https://avatars.githubusercontent.com/u/1281926?v=3","gravatar_id":"","url":"https://api.github.com/users/shahamit","html_url":"https://github.com/shahamit","followers_url":"https://api.github.com/users/shahamit/followers","following_url":"https://api.github.com/users/shahamit/following{/other_user}","gists_url":"https://api.github.com/users/shahamit/gists{/gist_id}","starred_url":"https://api.github.com/users/shahamit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shahamit/subscriptions","organizations_url":"https://api.github.com/users/shahamit/orgs","repos_url":"https://api.github.com/users/shahamit/repos","events_url":"https://api.github.com/users/shahamit/events{/privacy}","received_events_url":"https://api.github.com/users/shahamit/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-04-25T04:02:29Z","updated_at":"2015-04-30T18:54:51Z","closed_at":null,"body":"We were thinking if this library could help us to get statistics on how many static statements vs prepared statements are executed by the software (like the query count statistics). As prepared statements give a good performance boost to the database server (hard vs soft parsing in oracle) it would be very helpful if a query execution listener could detect whether the underlying query is a static query or a prepared statement. \r\n\r\nOur first thought was to implement the query listener and check if the getQueryArgsList() map is empty, but later came across some half cooked use cases which could turn this logic false like\r\n```\r\nselect emp_name from employee where emp_id = 24 and emp_type = ?\r\n```\r\n\r\nNow this would be termed as a prepared statement but since it has the emp_id parameter value hard coded it is not completely a prepared statement. The database server would still have to do hard parsing for this.\r\n\r\nI would like to start this as a discussion and get your experience to brainstorm if there is a better logic for this use case. Our goal is to let developers know that they should revise the queries being executed by their feature.\r\n\r\nThanks !\r\n\r\nP.S - Looking at the query transformer interface, I am keen on knowing what are some of the real world use cases of it. Please share them."},"comment":{"url":"https://api.github.com/repos/ttddyy/datasource-proxy/issues/comments/97925847","html_url":"https://github.com/ttddyy/datasource-proxy/issues/19#issuecomment-97925847","issue_url":"https://api.github.com/repos/ttddyy/datasource-proxy/issues/19","id":97925847,"user":{"login":"ttddyy","id":459116,"avatar_url":"https://avatars.githubusercontent.com/u/459116?v=3","gravatar_id":"","url":"https://api.github.com/users/ttddyy","html_url":"https://github.com/ttddyy","followers_url":"https://api.github.com/users/ttddyy/followers","following_url":"https://api.github.com/users/ttddyy/following{/other_user}","gists_url":"https://api.github.com/users/ttddyy/gists{/gist_id}","starred_url":"https://api.github.com/users/ttddyy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ttddyy/subscriptions","organizations_url":"https://api.github.com/users/ttddyy/orgs","repos_url":"https://api.github.com/users/ttddyy/repos","events_url":"https://api.github.com/users/ttddyy/events{/privacy}","received_events_url":"https://api.github.com/users/ttddyy/received_events","type":"User","site_admin":false},"created_at":"2015-04-30T18:54:51Z","updated_at":"2015-04-30T18:54:51Z","body":"It's kinda workaround check but how about this?\r\n\r\n```java\r\nprivate boolean isStaticStatement(ExecutionInfo execInfo, String query) {\r\n    StatementType statType = execInfo.getStatementType();\r\n    if (StatementType.STATEMENT.equals(statType)) {\r\n        return true;\r\n    } else if (StatementType.PREPARED.equals(statType) && !query.contains(\"?\")) {\r\n        return true;\r\n    }\r\n    return false;\r\n}\r\n```\r\n"}}