-1

i have around 3000 locations in a table.I need to get location details for only specific 1300 locations from total locations.Its time taking to select locations in where clause. Is there any way do that in sql columns in table are location id,location name and location code.

select location_id,location_id,location_code from location where location_id in ('','',''......)
nikhil
  • 149
  • 1
  • 2
  • 12
  • 3
    create another table and insert those 1300 locations, then join this table and your locations table together – OracleDev Jun 30 '22 at 06:16
  • can we load total data in excel and insert 1300 locations in another sheet and do vlookup?? – nikhil Jun 30 '22 at 06:33
  • why don't you do this in the database (create a new table and insert the data into it), why excel? – OracleDev Jun 30 '22 at 07:59

1 Answers1

1

Based on @OracleDev’s answer, To execute your query quickly, you can create a new table with the required 1300 locations and then you can join this table with the bigger table with 3000 location ids..

Example:

The new table contains only 1300 location ids that satisfy your condition and the other table contains 3000 location ids. When a new update is needed to the required location ids, the location table can be modified accordingly. There would be no need to change the query when the required ids change in turn the performance is not affected. I think this stackoverflow thread would be helpful as to why multiple IN operators reduce query performance.

kiran mathew
  • 1,882
  • 1
  • 3
  • 10