Subject Re: [firebird-support] Re: Performance problem - input wanted
Author Svein Erling Tysvær
Try changing to Afdeling_ID||'' (or Afdeling_ID+0 if it is a number) in your trigger. That should make RDB$FOREIGN105 useless for the query. Though this kind of trigger that finds the MAX value in huge tables (although there's only 750 occurences of each VAREPLU_ID on average, I guess there are some values that are used a lot more) is a source for inserts being slow as well as potentially error prone (in case of concurrent inserts, the same values would be returned for both rows, which may or may not be what you want).

HTH,
Set