1

I am having a million SELECT queries like

select id from accountTable where lastname ='' and firstName='' and zip='';

and will be using the PreparedStatement for that.

I know for batch I can use only insert/update/delete and never seen batches used for select statements.

In order to improve the performance, I want to execute it in the batch of 1000, may I know how can I do that in scala?

ernitingoel
  • 621
  • 2
  • 9
  • 24
  • 1
    [You can't run JDBC batch statements for selects](https://stackoverflow.com/questions/7899543/can-preparedstatement-addbatch-be-used-for-select-queries). So in your case, the only way to go is to create *bigger* queries. Maybe you could create big UNION query? – Krzysztof Atłasik Apr 18 '19 at 19:52
  • Possible Duplicate of: https://stackoverflow.com/questions/40790427/how-to-batch-select-data-from-cassandra-effectively – ShailyAggarwal Apr 18 '19 at 20:13
  • Can you share a little bit more of your code? How do you run your queries now? – Krzysztof Atłasik Apr 18 '19 at 20:29
  • If it's about processing several rows at a time, have you considered something like a library with support for streaming and then running things in a stream? Like e.g. slick + akka stream + alpakka slick (integration between the two), or doobie + fs2? – Mateusz Kubuszok Apr 19 '19 at 09:59

0 Answers0