in reply to Re^4: Dynamic SQL
in thread Dynamic SQL

If each prepared statement is used only once then, no, it won't be true. If each prepared statement is used a number of times then it will save the parsing time of the SQL queries each time a prepared statement is reused. The OP has given very limited examples and no sense of the number of possible unique (modulo the values that would go in the placeholders) queries

Replies are listed 'Best First'.
Re^6: Dynamic SQL
by erix (Prior) on Apr 06, 2015 at 17:21 UTC

    If each prepared statement is used only once then, no, it won't be true.

    for instance.

    And then there is the fickleness of planning.

    But I can see it would be hard to set up a broad, convincing case.

      This is generally the case with any caching or memoizing strategy: if the cached results are never re-used, then caching is an overhead. But still, there are many many cases where caching really make sense, it can sometimes transform a quadratic (and sometimes even exponential) algorithm into a linear one. Sometimes it is easy enough to analyze to figure out; in other cases, only benchmark can tell.

      Je suis Charlie.