Bank Sql Server 2012 and 2008.
I have been logged into the following error (sql server 2012):
error_reported 2017-12-27 09:14:16.2053050 8623 16 1 False 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.
SELECT DISTINCT COUNT(e.id_evento) AS count
FROM syo_evento AS e
INNER JOIN syo_encaminhamento AS en ON en.id_evento = e.id_evento
WHERE en.id_empresa IN (10)
AND e.id_evento IN (SELECT i.id_evento
FROM syo_interesse AS i
INNER JOIN syo_modeloversao ON id_modeloversao = CAST(i.ds_modelo AS INT)
WHERE i.ds_modelo != 'INDIFERENTE'
AND i.id_interesse = (SELECT MAX(id_interesse) FROM syo_interesse WHERE id_evento = i.id_evento)
AND id_modelo = 'STRADA')
AND (e.dt_limite <= 1514426360999 OR e.dt_proximaacao <= 1514426360999)
AND en.id_statusagenteativo = 'S'
AND e.id_evento IN (SELECT i.id_evento FROM syo_interesse AS i WHERE i.ds_marca = 'FIAT' AND i.id_interesse = (SELECT MAX(id_interesse) FROM syo_interesse WHERE id_evento = i.id_evento))
AND e.id_evento IN (5964767, 6377920, 6343493, 6343495, 6377927, 6060736, 6343496, 6377935, 6343498, 6343499, 6343509, 6377938, 6184147, 6343510, 6377940, 6377941, 6343504, 6377942, 6343507, 6343506, 6343517, 6377944, 6343512, 6343515, 6377951, 6343514, 6377953, 5999229, 6343523, 6377957, 6343532, 6377960, 6377967, 6343530, 6343531,
<frame level='1' handle='0x02000000B4EC8B31D255052CB504E32C1088771073F1F154' line='1' offsetStart='0' offsetEnd='0'/> <frame level='2' handle='0x000000000000000000000000000000000000000000000000' line='1' offsetStart='0' offsetEnd='0'/>
The above query is incomplete because the log has a character limit, I have reduced it further because of the StackOverflow limit but only in the IN part of the parameter, the query in the log (incomplete) has about 3550 parameters, but in the system I have seen searches with many more (hundreds of thousands), another detail is that it occurs 37 times, in a period between 09:14 and 11:32 in the morning.
My question is, is this problem caused solely by the number of parameters in the IN clause or may it have been aggravated by other queries?
For example, a heavy, multi-character query that takes a few seconds to execute, will the resources consumed by this large query affect the features of this other query that was run after or at the same time?
That is, in the case of this error the resources are divided or individual between the queries?