Subject | Re: [ib-support] Adding index does nothing to select disctinct |
---|---|
Author | Mark Patterson |
Post date | 2002-09-13T04:27:57Z |
Helen Borrie wrote:
of assumes there was some logical connection between indexes and sorting, and if
you have a sorted list with duplicates you don't need to walk the whole list.
is looking like the way we'll go.
range, before they can choose a job_number, the list could be made available
when they start entering the job_number. But if if still takes 8 seconds,
because they want a report over the last 2 years...
thanks again.
mark
> At 10:39 AM 13-09-02 +1000, you wrote:That depends how the index works. I don't know the mechanics of it, but I sort
>influence the speed very much. What is your WHERE clause like? If you add
>>
>>OK, what you're saying is that SELECT DISTINCT doesn't know how to take
>>advantage of indexes. Maybe that can be an enhancement for version 2.0.
> It's hard to see how it could, since SELECT DISTINCT has to get a distinct
> occurrence of all the columns named in the output set. The logic of that
> involves intermediate sets. Even in your case, where you have only one
> column, it still has to walk the whole table to eliminate the duplicates,
> because you have no limiting clause.
of assumes there was some logical connection between indexes and sorting, and if
you have a sorted list with duplicates you don't need to walk the whole list.
> I avoid SELECT DISTINCT if speed matters, and structure the table and/orSounds sensible, but not in harmony with the general idea of normalization. That
> the query so that I can use a WHERE clause. In your example, I'd certainly
> have a JOB table where JOB_NUMBER is unique.
is looking like the way we'll go.
> But if you can't do that, at least limit the rows by some means (e.g. date)Hmmm... yes, if the user enters the date range, and there is an index on date
> so that your query has a smaller set to walk.
range, before they can choose a job_number, the list could be made available
when they start entering the job_number. But if if still takes 8 seconds,
because they want a report over the last 2 years...
thanks again.
mark