In a WebApi which third parties consume, today we started experiencing failures when they call a method.

The method connects to a couple of tables and joins them. The error message from EF is

> 
> 
> > 
> > The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.
> > 
> > 
> > 
> 
> 
> 

```
return context.leads
            .Where(q => q.eventID == 1234)
            .Join(context.config,
                leads => leads.configId,
                config => config.configId,
                (leads, config) => new { leads, config })
            .Where(p => keys.Contains(p.leads.leadId))

```

keys is a IEnumerable of retrieved lead ids. Basically we pull the list of ids and then we do the above, checking the keys collection so that our query returns accurate data.

keys holds about 28k ids.

Note that this has only started being an issue since migrating to Azure cloud, but I think that is a coincidence