When NOT to use placeholders

djberg96 on 2004-07-15T18:03:24

As a general rule you want to use placeholders whenever possible, as opposed to interpolated statements. So, when might you not want to use placeholders (in Oracle)?

I never really knew until today. Tim Bunce's Programming the Perl DBI (somewhat dated - I haven't checked the latest docs) doesn't say much on the subject other than, "don't use them if your vendor doesn't support them (duh)".

Here's where Guy Harrison's book has enlightened me yet again. The answer? Histograms.


Re: When NOT to use placeholders

dws on 2004-07-15T21:26:23

Using placeholders in LIKE clauses is problematic. RDMBSs that prepare queries usually build the execution plan at prepare time. But without knowing what the LIKE clause looks like (e.g., 'foo%' vs. '%foo'), the query planner has to assume worst-case, which means a full table scan. Oracle has some knob you can twist to get better behavior, but it's buried in the docs.

Re: When NOT to use placeholders

djberg96 on 2004-07-20T18:50:05

Oracle has some knob you can twist to get better behavior, but it's buried in the docs

There's probably a hint you can use. While I think hints are both nice and powerful, there is simply no way your average developer is going to remember them all. At least, I doubt that I ever will.