Is it more performant to use a Prepared Statement with one question mark in it fifty times, or to use a Prepared Statement with fifty question marks in it once?
Essentially is Where Person = ?
or Where Person IN (?, ?, ?, ...)
better?
Example
Say you have a table with a column, country, and then a few relational tables away you have the population for that country.
Given a list of 1000 countries, what is the best way to go about getting the population?
Keep in mind this is a hypothetical example, Wikipedia puts the number of countries at 223, let's assume for this example it is much larger.
Create a statement that takes in a country parameter and returns a population. Example:
Where Country = ?
Create a Prepared Statement dynamically, adding a ? for each country using a
Where in (?,?,etc)
clause. Example:Where Country = (?, ?, ...)
Create a simple statement like in option one, but loop through and reuse the one parameter Prepared Statement for each country.
What is the preferable method?