Subject | Re: [firebird-support] Very slow SQL |
---|---|
Author | Alexandre Benson Smith |
Post date | 2007-08-21T20:23:20Z |
Ed Dressel wrote:
select * from ClientINfo
where Client_Id = (Select Max(Client_ID) from ClientInfo)
add a descending index on ClientInfo(Cliente_ID)
see you !
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br
> I have the following SQL statement:Max(Client_ID) will return just one value, so change IN to =
>
> select * from ClientINfo
> where Client_Id in (Select Max(Client_ID) from ClientInfo)
>
> where Client_ID is the primary key of ClientInfo.
>
> But the SQL above is very slow (almost 2 minutes). The plan is nautrual:
>
> PLAN (CLIENTINFO NATURAL)
> PLAN (CLIENTINFO NATURAL)
>
select * from ClientINfo
where Client_Id = (Select Max(Client_ID) from ClientInfo)
add a descending index on ClientInfo(Cliente_ID)
see you !
--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br