Subject | Optized index |
---|---|
Author | skander_sp |
Post date | 2006-02-06T14:59:59Z |
A table with a long amount of records has two main fields
N_Year as Smallint
N_Doc as integer
In the trigger before insert I load N_Doc as higher numer of same
year, this way:
select coalesce(max(N_Doc),0)+1
from Docs
where N_year=new.N_year
into new.N_Doc;
I need this operatios was quick, every time, (growing 500 rec/day)
But I need also a quick search in sequental select for report
select *
from Docs
where N_year=:N_Year
order by N_Doc;
I'm using index UNIQUE (N_Year, N_doc) for this table, but I think
this way is not much usefull for the insert trigger, but descending
indes was not usefull for select... may be descending work better?
Someone can help me? what can be TWO index optimized for both? or what
only one can solve both problems...
will be nice some REAL experience with same case, not only theoria.
Tks
Alejandro
N_Year as Smallint
N_Doc as integer
In the trigger before insert I load N_Doc as higher numer of same
year, this way:
select coalesce(max(N_Doc),0)+1
from Docs
where N_year=new.N_year
into new.N_Doc;
I need this operatios was quick, every time, (growing 500 rec/day)
But I need also a quick search in sequental select for report
select *
from Docs
where N_year=:N_Year
order by N_Doc;
I'm using index UNIQUE (N_Year, N_doc) for this table, but I think
this way is not much usefull for the insert trigger, but descending
indes was not usefull for select... may be descending work better?
Someone can help me? what can be TWO index optimized for both? or what
only one can solve both problems...
will be nice some REAL experience with same case, not only theoria.
Tks
Alejandro