I have a table (UserDeptMapping) which conatins 129000000 (one hundred twenty-nine millions records).
Department details table which has 500 entries.
ID | DeptId | WorldLocationId | RegionId | DistrictId |
Table UserDeptMapping which contains below data like
| Id | UsertId | MappingId |
| 1 | 1 | 1 |
| 2 | 1 | 2 |
| 3 | 1 | 3 |
| 4 | 2 | 1 |
Suppose execute below query against Department Id 1 like
- Select * from UserDeptMapping Where MappingId = 2
Output comes with total 300000 rows which is taking 30 seconds.
How can I optimiase the query., so it will reduce the time.


Gowtham RamarRank #1,754 · 860 reputationPosted Apr 4, 2019, 5:29 AM EDT
Vishal KadamRank #7,785 · 234 reputationPosted Apr 4, 2019, 1:25 PM EDT
Amit GuptaRank #190 · 12.8K reputationPosted Apr 5, 2019, 3:00 AM EDT