Subject Re: [firebird-support] Optimizing SELECT DISTINCT ..
Author Harriv
On Tue, Feb 3, 2009 at 1:27 PM, Douglas Tosi <douglasht@...> wrote:
> On Tue, Feb 3, 2009 at 9:11 AM, Harri Vartiainen <harriv@...> wrote:
>> What would be best way to optimize "SELECT DISTINCT FIELD1 FROM
>> TABLE1 ORDER BY FIELD1" query?
>
> Not sure if it's the best, but try:
> SELECT FIELD1 FROM TABLE1 GROUP BY FIELD1
> This should use the index for an ordered fetch.

Yes it does, but according to statistics it still reads whole table.
The number just moves from "Non-indexed" to "Indexed" in DBWorkbench.

>
> hth,
> --
> Douglas Tosi
> www.sinatica.com
>