Subject | Index not picked up by optimizer |
---|---|
Author | dr_bentonquest |
Post date | 2007-03-02T18:03:53Z |
Hi there,
I have an INVOICES table like this:
create table INVOICES
(
NUMBER integer,
CUSTOMER integer,
INVOICETOTAL numeric(10,2),
...more fields...
)
I set up an index like this:
CREATE INDEX INV_TOTAL on INVOICES(CUSTOMER,INVOICETOTAL);
Now when executing the following query, the index is picked up
correctly in the plan:
SELECT SUM(INVOICETOTAL) FROM INVOICES
WHERE CUSTOMER=123 AND INVOICETOTAL > 0;
However, for the following queries the index is NOT picked up:
SELECT SUM(INVOICETOTAL) FROM INVOICES
WHERE CUSTOMER=123 AND INVOICETOTAL <> 0;
SELECT SUM(INVOICETOTAL) FROM INVOICES
WHERE (CUSTOMER=123) AND (NOT INVOICETOTAL = 0);
I'm currently using FB 1.5.3. Is there any workaround I could use to
solve this? I need the total for invoices where the INVOICETOTAL field
is not zero.
Thanks in advance,
-Benton
I have an INVOICES table like this:
create table INVOICES
(
NUMBER integer,
CUSTOMER integer,
INVOICETOTAL numeric(10,2),
...more fields...
)
I set up an index like this:
CREATE INDEX INV_TOTAL on INVOICES(CUSTOMER,INVOICETOTAL);
Now when executing the following query, the index is picked up
correctly in the plan:
SELECT SUM(INVOICETOTAL) FROM INVOICES
WHERE CUSTOMER=123 AND INVOICETOTAL > 0;
However, for the following queries the index is NOT picked up:
SELECT SUM(INVOICETOTAL) FROM INVOICES
WHERE CUSTOMER=123 AND INVOICETOTAL <> 0;
SELECT SUM(INVOICETOTAL) FROM INVOICES
WHERE (CUSTOMER=123) AND (NOT INVOICETOTAL = 0);
I'm currently using FB 1.5.3. Is there any workaround I could use to
solve this? I need the total for invoices where the INVOICETOTAL field
is not zero.
Thanks in advance,
-Benton