The problem is not your crossCompany query at all.
It's entirely the location.delete() method. Let's look closer.
The LogisticsLocationEntity::canDeleteLocation(..) method does a tremendous amount of work.
It loops through a list of tables checking to see if the delete is valid or not.
Let's look at LogisticsLocationEntity::locationtableList().
static client server container locationTableList()
{
container list;
list = [tableNum(AssetLocation) ,fieldNum(AssetLocation,LogisticsLocation)
,tableNum(BankAccountTable) ,fieldNum(BankAccountTable,Location)
,tableNum(BankGroup) ,fieldNum(BankGroup,Location)
,tableNum(CustBankAccount) ,fieldNum(CustBankAccount,Location)
,tableNum(CustInvoiceTable) ,fieldNum(CustInvoiceTable,DeliveryLocation)
,tableNum(IntrastatParameters) ,fieldNum(IntrastatParameters,AgentLocation)
,tableNum(IntrastatServicePoint_FI) ,fieldNum(IntrastatServicePoint_FI,Location)
,tableNum(ProjInvoiceTable) ,fieldNum(ProjInvoiceTable,InvoiceLocation)
,tableNum(ProjTable) ,fieldNum(ProjTable,DeliveryLocation)];
list +=
// ,tablenum(PurchReqLine) ,fieldnum(PurchReqLine,DeliveryLocation)
[tableNum(SalesBasket) ,fieldNum(SalesBasket,DeliveryLocation)
,tableNum(SalesCarrier) ,fieldNum(SalesCarrier,Location)
,tableNum(SalesQuotationBasket) ,fieldNum(SalesQuotationBasket,DeliveryLocation)];
list +=
[tableNum(Tax1099SoftwareVendParameters) ,fieldNum(Tax1099SoftwareVendParameters,Location)
,tableNum(Tax1099TransmitterParameters) ,fieldNum(Tax1099TransmitterParameters,Location)
,tableNum(TaxAuthorityAddress) ,fieldNum(TaxAuthorityAddress,Location)
,tableNum(TaxEvatParameters_NL) ,fieldNum(TaxEvatParameters_NL,ContactLocation)
,tableNum(TaxIntraCommTable_NL) ,fieldNum(TaxIntraCommTable_NL,ContactLocation)
/* ,tablenum(TrvExpTrans) ,fieldnum(TrvExpTrans,LogisticsLocation)*/
,tableNum(VendBankAccount) ,fieldNum(VendBankAccount,Location)
/* ,tablenum(VendRequest) ,fieldnum(VendRequest,BankLocation)
,tablenum(VendRequest) ,fieldnum(VendRequest,cContactLocation)
,tablenum(VendRequest) ,fieldnum(VendRequest,cLocation)
,tablenum(VendRFQJour) ,fieldnum(VendRFQJour,DeliveryLocation)*/];
return list;
}
That's why it takes so long to delete one LogisticsLocation record.