Subject Re: Optimize max query in select
Author diwic2
> > select nodeid, max(pid)+1 as q
> > from my_messages group by nodeid
> >
> Have you tried creating a descending index on the field you
calculate
> 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 numbers
then
> you should be aware that this approach isn't safe in a concurrent
> multi-user system.

Well, I am the single application instance writing and reading from
this table, so this is not a problem. Thanks for the hint anyway.

// David