Subject Re: [firebird-support] Exclude records from index
Author Kjell Rilbe
ck1625 skriver:
> is it possible to create an index, but exclude records with values NULL
> and 0 in the index column for the index?
>
> I have a log table with millions of records, but maybe only 5-10% have a
> value in this specific field. And if I ever do a query using this value,
> only records with values <> NULL or 0 are relevant.

I also have a few of those. I have two tables with 150 million records
each, and for a couple of associations (in UML terms) I have rather few
"entries" but for those that exist, having an index for joins is
essential. So, a few indices on these large tables have perhaps 98% NULL:s.

One solution might be to add a link table, as if the link was
multi-multi. Then that smaller link table would contain two indices that
would be only on those 1-2% of the 150 million records. On the downside,
it will require an extra table join.

Kjell
--
------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell.rilbe@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64