Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2013-06-16 : 07:00:30
|
I have a query select participantid,lastname,firstname,nameofprogram, status from participants order by lastname,firstnamewe are doing this at the top of every page and it's taking time to load(part of the issue I believe is the shared sql server we are on)I already have an index on lastname,firstnameis there anyway I can make this query quicker?alternatively i was thinking to cache this query in a table and when the table is updated - change the updated info == maybe to do this in sql and maybe on the server just in a text filewhat do you think? |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-06-16 : 12:42:00
|
Given that your query does not have any WHERE clause or HAVING clause to limit the number of rows, the query is going to do a table scan, so indexes are probably not of going to be much help. If you are doing this select frequently, assuming the table is not very large, it should not result in any physical IO's; just logical IOs. How many rows does the table have?Your best bet is to turn statistics on to see what is going on. I don't think your idea about caching the table is not going to help much either - but I am only guessing; first you need to find where the bottleneck is. Query plan and statistics will help you do that. |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2013-06-16 : 13:26:29
|
there are 3754 rowsexecution plan is select 0%sort 17%table scan 83%what can I do?we need this list of the users in many places |
|
|
|
|
|