scala - Slick 3.0 avoid multiple selects -


i have collection of long , each element in collection, have lookup table in database , select. problem approach issues many selects , every time there new connection being opened , when make multiple calls method, connection pool exhausted soon!

val allids = seq(1,2,3,4....) 

for each id in allids, do:

db.run(fetchtablerowfromdb(_)) 

is there better way avoid giving many select statements?

you can use bulk fetch . assuming table class name "sampletable" , table name "sampletable".

val allids = seq(1,2,3,4....) val query = tablequery[sampletable].filter(_.id inset(allids.totraversable)) db.run(query) 

the above query similar

select * sampletable id in (1,2,3....); 

Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -