Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many bind variables can I use in a SQL query in MySQL 5?

Tags:

mysql

Is there a limit to the number of bind variables I can use in a query in MySQL 5? I assume that there is, but I can't find any information in the reference manual or by Googling.

The only thing that I could find that provides any information at all is in the C API reference: http://dev.mysql.com/doc/refman/5.0/en/mysql-stmt-bind-result.html

This seems to imply that memory is the only limit, but that seems a bit suspect.

Update: there is a limit!

runner.rb:47: data_replicator.rb:312:in `prepare': Prepared statement contains too many placeholders (Mysql::Error)
        from data_replicator.rb:312:in `set_statement_handle_for'
        from data_replicator.rb:287:in `log_query'
        from data_replicator.rb:221:in `replicate_table'
        from data_replicator.rb:93:in `replicate'
        from data_replicator.rb:20:in `run'

This gives me something better to search on!

like image 406
Josh Glover Avatar asked Feb 07 '11 14:02

Josh Glover


1 Answers

There is limit 65,535 (2^16-1) place holders in MariaDB 5.5 which is supposed to have identical behaviour as MySQL 5.5.

Not sure if relevant, I tested it on PHP 5.5.12 using MySQLi / MySQLND.

like image 156
Martin Avatar answered Oct 14 '22 14:10

Martin