Domanda

I am using java. I have 2000 key values in object level and have to fetch the corresponding records for that values from the DB. I found temp table advice here, but won't it affect performance? How do I insert those values in a single shot, so that I can reduce the number of DB calls?

È stato utile?

Soluzione

You can use

col1 in (1,2...)  or col1 in (1001, 1002...)

Altri suggerimenti

I'd say the temp table is the way to go. Will it affect performance? Yes, it might be slightly slower than just hardcoding all of the values. But you can't have everything -- if you don't want to hardcode all of the values, you'll have to accept a small decrease in performance. I think the trade-off is satisfactory, particularly since the impact will probably be quite small.

for a single in clause - you cant. see discussion here.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top