Subject Re: [firebird-support] Speed of comparing one field to another
Author Walter R. Ojeda Valiente
Yes, you can, using an expression index

CREATE INDEX IDX_MYINDEX ON MY_TABLE COMPUTED BY (INVOICED - RECEIVED);

and your SELECT would be:

SELECT
   *
FROM
   MY_TABLE
WHERE
   INVOICED - RECEIVED < 0

That way you will not need to create an additional column neither to do an UPDATE neither to create a trigger.

Greetings.

Walter.


On Tue, Sep 13, 2016 at 9:26 AM, Maya Opperman maya@... [firebird-support] <firebird-support@yahoogroups.com> wrote:
 

Hi,

 

I have a large table, and I’m only extracting a few records using:

 

Select t.ID

From my_table t

Where t.Invoiced < t.Received

 

Invoice and received are of type decimal(18,5)

 

IBExpert is reporting these as unindexed reads.

 

Is there an index I could create to speed up the loading?

 

Thanks in advance

Maya