How do I improve database query time?

Any of these, or all of these in various combinations, could be causing slow query performance. In order to understand, you need to use the various monitoring and reporting tools that you have available in order to arrive at a root cause. That will then inform you what you need to do in order to improve performance.

There just is not a single answer possible to this question. It completely depends on why the query is running slowly. It could be a problem with your configuration of your server, network, virtual machine or disk subsystem. It might be problems with your database design. It could be incorrect or missing indexes. It might be that your statistics are out of date. It could be caused by conflict for resources caused by other queries. More often than not, it's that the code you have written isn't optimal for performing the action you expect of the query.

Any of these, or all of these in various combinations, could be causing slow query performance. In order to understand, you need to use the various monitoring and reporting tools that you have available in order to arrive at a root cause. That will then inform you what you need to do in order to improve performance.