diff --git a/src/org/labkey/targetedms/query/TargetedMSForeignKey.java b/src/org/labkey/targetedms/query/TargetedMSForeignKey.java index 974fa7a9c..1804d7d0e 100644 --- a/src/org/labkey/targetedms/query/TargetedMSForeignKey.java +++ b/src/org/labkey/targetedms/query/TargetedMSForeignKey.java @@ -38,8 +38,9 @@ public TargetedMSForeignKey(TargetedMSSchema schema, String tableName, Container @Override public TableInfo getLookupTableInfo() { - TableInfo table = _schema.getTable(_tableName); - ((TargetedMSTable)table).setNeedsContainerWhereClause(false); - return table; + // Avoid applying a container filter on lookups. The import process should be only creating FKs to data + // in the same container. Thus, we can rely on the outer query doing the proper filtering and avoid + // what can be expensive multi-table joins to get to a table that has the Container column we need + return _schema.getTable(_tableName, ContainerFilter.EVERYTHING); } } diff --git a/src/org/labkey/targetedms/query/TargetedMSTable.java b/src/org/labkey/targetedms/query/TargetedMSTable.java index f9d0c4e3a..7c6a0c75f 100644 --- a/src/org/labkey/targetedms/query/TargetedMSTable.java +++ b/src/org/labkey/targetedms/query/TargetedMSTable.java @@ -89,11 +89,6 @@ protected void applyContainerFilter(ContainerFilter filter) // Don't apply the container filter normally, let us apply it in our wrapper around the normally generated SQL } - public void setNeedsContainerWhereClause(boolean needsContainerWhereClause) - { - _needsContainerWhereClause = needsContainerWhereClause; - } - @Override @NotNull public SQLFragment getFromSQL(String alias) @@ -102,7 +97,7 @@ public SQLFragment getFromSQL(String alias) sql.append(super.getFromSQL("X")); sql.append(" "); - if (_needsContainerWhereClause || _containerTableFilter != null) + if (getContainerFilter() != ContainerFilter.EVERYTHING || _containerTableFilter != null) { sql.append(_joinType != null ? _joinType.getSQL() : "");