0

First of all, this is not a question about prepared statements themselves I have already checked a couple of articles like this.

My questions are about performance concerns while I'm starting my app I want to prepare the standard statements and leave them open during the lifetime of the program like the DB connection itself.

So I have two questions.

If I leave them open and my program dies will they terminate as the DB connection drops or will still keep some place in the MySQL cache.

Is there a better approach to this or is this an evil plan.

nikoss
  • 3,254
  • 2
  • 26
  • 40
  • The documentation indicated that the prepared query will exist for the lifefime of the session (connection). If it returns rows then ensure you fetch them all otherwise it will block other queries on the session. I would be tempted to try it with some benchmarking and see if the extra complexity is worth it? – Ryan Vincent Jun 11 '17 at 00:27
  • If I understand correctly I should close each time, in this case, there's really no point of using prepared statements unless I'm using some kinda loop. Could you please share this as an answer including the doc. Thank you @RyanVincent – nikoss Jun 11 '17 at 01:44

0 Answers0