On 4/9/21 7:11 AM, mailing lists via beginners wrote:
thanks Andrew

I need to insert millions of rows so I need to have a good performance using placeholders



You can not use placeholders for the table name.

If you have millions of *tables*, there is something very, very, very wrong with your database design.

"Premature optimization is the root of all evil" -- do you have hard numeric evidence that the time to create the statement-handle is the bottleneck in your system, or are you leaping to the conclusion that you "need" to parameterize the table name?

If you have only a few dozen tables, and you need the same statement for all of them, then something like

my %sth_for_table;
for my $table qw / foo bar baz waldo pepper salt pork … chains/ {
  $sth_for_table{$table} = $dbh->prepare("whatever whatever into $table");

}

then use the appropriate $sth from the hash for your execute.

That said: Needing to parameterize the *table name* is an absolute sure sign that "You're doing it wrong"


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to