On 05/02/2026 11:41, Lester Caine wrote:
> I seem to remember that once I have an index on the primary key that
> removes the need to add further indexes on the same fields, so for
> example I have 'm_file' and 'm_id' as a primary key on 'media' so there
> is no need to add a unique index on 'm_id' and 'm_file' and it does
> actually fail as a duplicate.
I'm not sure I understand your question correctly.
Having a primary key (m_file, m_id) does not remove the need for an
index (m_id) if you need to look up on m_id. It can prevent the need for
an index (m_file), as Firebird can search the prefix of the primary key
index (it cannot search the suffix).
Additionally, defining a _unique_ index (m_id) and _unique_ index
(m_file) achieves something else from the primary: instead of requiring
that the combination of (m_file, m_id) is unique, it requires that
m_file and m_id are individually unique. To me would that suggest that
maybe the primary key should be either (m_file) or (m_id), not (m_file,
m_id).
Mark
--
Mark Rotteveel