Preventing Indexes on Foreign Keys
Posted in 1998
Topics: Performance & Tuning, Triggers, Constraints & Referential Integrity, Platform-Specific Issues
Hi everyone,
I have several tables that I create with Foreign Keys on columns, but I
do NOT want Informix to automatically put an index on some of these
columns. Is there a way to prevent this?
In addition, can anyone tell me why Informix does this? I definitely
see situations where an index on a FK would be detrimental to
performance. For example, assume a table has 3 columns: site_id,
date_time, data1, where site_id is a FK with possible values of 1 to 20.
Now assume a new row is inserted into this table every 10 seconds 24
hours a day 7 days a week, where the table on the average contains 2
million rows. Now assume that all queries have the following form:
SELECT date_time, data1
FROM table
WHERE date_time BETWEEN "1998-03-10 00:00:00" AND "1998-03-10 01:00:00"
AND site_id = 1
ORDER BY date_time;
From a performance view: An index(date_time) or an index(date_time,
site_id) would drastically improve performance, but an index only on
site_id will not give a big improvement, since the selectiveness of the
index is only 1/20. Therefore, performance would be degraded for all
the inserts and the select performance would increase slightly. My
thoughts on this would be to drop the index on the site_id, which is the
FK, and put one index(date_time, site_id). ie. I don't want Informix
to automatically put an index on the site_id, the FK.
Are there any other opinions out there?
I'm using HP-UX 10.10 with Informix Online 7.13.UC5.
TIA,
Jim Koermer
USCG Loran Support Unit, Wildwood, NJ.
jkoermer@lsu.uscg.mil