Subject | Re: Looking for advice on indexes |
---|---|
Author | bimmer_r |
Post date | 2013-05-03T12:07:23Z |
With what you are describing (3 columns - no primary key or index) I would create a full index (all 3 columns).
You can play with optimizers - to see if there are any gain in having WORK_DATE in the index. But I don's think you will be able to see it.
I could be wrong though :-)
I'm could also assume that :
ID is SITE_ID and that it is PK with autoinc.
And that you do updates more than inserts.
Since you are grouping by PK (integer) I don't see you can gain anything with an index.
HTH
Bimmer_R
You can play with optimizers - to see if there are any gain in having WORK_DATE in the index. But I don's think you will be able to see it.
I could be wrong though :-)
I'm could also assume that :
ID is SITE_ID and that it is PK with autoinc.
And that you do updates more than inserts.
Since you are grouping by PK (integer) I don't see you can gain anything with an index.
HTH
Bimmer_R
--- In firebird-support@yahoogroups.com, Marcin Bury <marcin.bury@...> wrote:
>
> Hello All
>
> 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?
> Currently I have around 5000 records in the table.
>
> Thanks in advance
> Marcin
>