Subject Re: Better procedure for "horizontal table"?
Author Richard Saeger
--- In ib-support@y..., Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:

Set,

You are _absolute_ on the right way.

I've changed the primary key from (Work_Day, Emp_No) to (Emp_No,
Work_Day) and the procedure run 25-times faster!

Thank you very much.
See you later :-).

Richard

> One thing I suddenly realised: Your PK is (Work_Day, Emp_No). That
means
> that IB has to look up every individual date (since you use BETWEEN
and is
> interested in more than one date) and then try to find the
employee. If
> your PK was the other way around (Emp_No, Work_Day), then IB could
just
> locate the employee once find the first work_day and then traverse
down the
> work_days (since they would be in sequence). I think that would be
worth a
> try.
>
> HTH,
> Set