2

My table has 2 million records. I want to select distinct values from the table. If I use select distinct... it may take more time. What would be another option to select distinct values in less time.

Rony
  • 31
  • 4

3 Answers3

0

If you've done proper indexing, then SELECT DISTINCT should be the fastest way here.

Gregor Menih
  • 5,036
  • 14
  • 44
  • 66
0

GROUP BY? or having another table with just distinct values modified by triggers on insert, delete, update to the original table?

rezna
  • 2,243
  • 2
  • 17
  • 16
0

If you want to select distinct, you have to select distinct.

Here are few things you can do to make it faster:

  1. Index the columns you are selecting distinct upon.
  2. Use a clustered index if possible.
  3. Partition your data so make searching faster.

2 million rows is big but not at all unheard of for a database.

nunespascal
  • 17,584
  • 2
  • 43
  • 46