Subject RE: [firebird-support] using indices
Author Mercea Paul
Instead select sum(saldo) from fac_com where (saldo<>0)

If you try

select sum(saldo) from fac_com where (saldo<0 or saldo>0)

You get the plan:

PLAN (FAC_COM INDEX (FAC_COM_IDX4, FAC_COM_IDX4))



Regards,

Paul





From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Sergio H. Gonzalez
Sent: Thursday, September 18, 2008 9:28 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] using indices



Mmmh... I think I understand now that "value <> 0" can't use index... Am I
wrong?

I've changed
> CREATE INDEX FAC_COM_IDX4 ON FAC_COM (SALDO);
for
CREATE INDEX FAC_COM_IDX4 ON FAC_COM COMPUTED BY (ABS(SALDO));

and
> select sum(saldo) from fac_com where (saldo<>0)
for
select sum(saldo) from fac_com where ABS(SALDO)>0

and now I get the plan:

Plan
PLAN (FAC_COM INDEX (FAC_COM_IDX4))

So is that the correct way to do it?

thanks!

-s





[Non-text portions of this message have been removed]