Subject RE: [firebird-support] Looking for advice on indexes
Author Leyne, Sean
Marcin,

> I have following table named TSH:
>
> ID INTEGER
> SITE VARCHAR(50)
> WORK_DATE DATE
>
> each day there are 10 up to 15 records inserted with various sites.
> The list of sites is quite limited and consists of around 50 items.
>
> Then I have following query
>
> SELECT SITE_ID, MAX(WORK_DATE)
> FROM TSH
> GROUP BY 1
>
> to get the latest entry for each site
>
> What indexes should I create to get this query as quickest as possible?

For this query, a DESCENDING compound index with the ID and WORK_DATE would be best.


Sean