Oliver Jowett <oliver@opencloud.com> writes:
> If I patch Hibernate to not add a FK constraint at all, it runs
> substantially faster. It does not seem trivial to fix Hibernate to add
> an index in this case -- Hibernate wants to run "ALTER TABLE tablename
> <dialect specific sql>" to add a FK constraint, but we need to execute
> "ALTER TABLE tablename ADD CONSTRAINT ...; CREATE INDEX .... ON
> tablename ..." and the dialect code is not given "tablename".
> So to fix this properly needs some work on the Hibernate side.
That division of labor seems more than a tad brain-dead anyway;
who's to say that the appropriate dialect-specific command is an
ALTER TABLE at all? It would be better if the dialect-specific
code were responsible for emitting the entire command --- in which
case it would have the tablename too and could do the Right Thing.
So I'd suggest filing a bug/enhancement request against Hibernate.
regards, tom lane