Subject Re: plan & performance
Author Sergio
> Another option is to have another table, populated through a trigger that generally store id_monetas, id every time you store a record, and that every once in a while (maybe each night or even once every hour) run:


Hi Set!! Thank you very much for your input! Thinking in your last idea I did this:

1. Add a new field into MONEDAS:

CREATE TABLE MONEDAS (
[...]
ID_MONEDAS_VALORES_MAX FK_ID);

2. And then this very simple trigger in MONEDAS_VALORES:

CREATE TRIGGER MONEDAS_VALORES_BI0 FOR MONEDAS_VALORES
ACTIVE BEFORE INSERT POSITION 0
AS
begin
update monedas
set id_monedas_valores_max = new.id
where id = new.id_monedas;
end

So now I have all the fields I need in a single table... I've always been reluctant to have duplicated fields in my databases, but seeing that you (who knows SQL very well) suggested to create another table to improve performance, I thought "it can't be that bad to create a field!!" Now the select takes 0s and the trigger doesn't affect the system performance at all, of course.

Thanks again!

-sergio