|Subject||Re: Optimize max query in select|
> > select nodeid, max(pid)+1 as qcalculate
> > from my_messages group by nodeid
> Have you tried creating a descending index on the field you
> the max() for?CREATE DESCENDING INDEX "INDEX1" ON "MY_MESSAGES"("PID");
Yes. It does not change the plan (i e it does not use the index).
PLAN (MY_MESSAGES ORDER RDB$PRIMARY3)
> Also, if you're doing this to get an auditable series of numbersthen
> you should be aware that this approach isn't safe in a concurrentWell, I am the single application instance writing and reading from
> multi-user system.
this table, so this is not a problem. Thanks for the hint anyway.