chpicker
Programmer
- Apr 10, 2001
- 1,316
I am trying to pull a list of unique items from a table. The table has 850,000 records in it. Each record has a unitnum field in it, and I want to pull out a list of how many different unitnums are present. I tried 2 different SELECT statements:
Both of these statements return the same results, but take almost 12 seconds to process, returning only 47 records. The table is indexed on the unitnum field. How can I optimize this query so it pulls these 47 records out faster? I thought it would be almost instant, but it isn't. I even tried changing the unitnum tag to UNIQUE instead of REGULAR, and it still takes as long. Any suggestions to get it to work faster?
Code:
SELECT unitnum FROM (masterlist) GROUP BY unitnum
SELECT DISTINCT unitnum FROM (masterlist)