SQL Server hangs when running query with multiple joins on empty tables - sql-server
We have experienced what appears to be an interesting bug in SQL Server that I would like to describe to you. I am hoping to find out if it IS actually a bug, and if so where I can found out more information about it. If it is not a bug, I hope somebody can explain to me why it is not and what we have unwittingly done wrong. I can't seem to find description of a similar issue and I'm not sure if we should report to Microsoft as a bug or what. I will first describe the problem briefly and provide details after.
In short, the problem seems to be that SQL Server chokes on statements containing many joins when some (large?) portion (sorry, can't be more specific here in terms of numbers) of the tables being joined are empty. By choke, I mean that it churns and churns away at the query, never finishing, which causes SQL Server to stop responding entirely. Actually, running the query once causes the CPU to jump to 25% and stay there. Another attempt and CPU jumps to 50%. Sometimes, CPU would go to 75% or 100%, but at the 50% mark, you can't even log in to the database server any more.
The problem occurs in an application that we have that uses Hibernate (via Coldfusion ORM) and has an entity (Document) that is sub-classed into many different types of document. The SQL query in question is generated by Hibernate when we run a query on the base class Document (e.g. "FROM Document WHERE Locked=1"). This results in a very long SQL query that joins all the sub-class tables together (example below) and sometimes kills the server.
A few things of interest that I found while testing:
It ONLY happens when there are a large number of empty joined tables, which is why it was such a bear to track down - never happened when running on our dev or testing databases because they had ample data. So the same query runs instantaneously without issue in one instance and completely kills SQL server in another.
I thought at first that the large number of selected columns in the SQL query might be causing an issue so I tested the SQL query with the same joins but only selected a single column from each table so only a small amout of data was actually being selected - no improvement, still hung.
I ran the query against the DB that had little data and I started removing the joins one by one. I found I could get to a point where the query would run and run quickly. Adding a join back from this point would cause the query to run, but noticeably slower, and repeating this a few more times would eventually cause it to grind to a halt again and kill the server.
So based on the above I've surmised that there is a bug (or a known fact of which I am ignorant) in SQL Server whereby joins resulting in too many nulls cause an issue. I think it might be a bug rather than a known limitation because it does not result in an error message (like, for example, you would get if you attempted a query with more than 2100 items in an IN clause), but rather a hung server. The server goes into la-la land almost like the joins had resulted in a cartesion product, but it's the opposite - instead of huge amounts of data, I have no data.
Has anybody else ever encountered such an issue? Is there some known limit of SQL server that I am rubbing up against? I have had great difficulty googling the issue because it is hard to define.
Should I file a bug with Microsoft for this?
Any insights are greatly appreciated. If any more information is needed from me, please let me know.
Thanks.
Example query follows (I've removed most of the selected columns for brevity):
select
top 1 document0_.ID as ID715_,
document0_.CreatedOn as CreatedOn715_,
document0_.UpdatedOn as UpdatedOn715_,
document0_.DeletedOn as DeletedOn715_,
document0_.Deleted as Deleted715_,
document0_.Active as Active715_,
document0_.ActivatedOn as Activate8_715_,
document0_.DeactivatedOn as Deactiva9_715_,
document0_.Locked as Locked715_,
document0_.CompletedDate as Complet11_715_,
document0_.CreateUserID as CreateU23_715_,
document0_.UpdateUserID as UpdateU24_715_,
document0_1_.CreatedOn as CreatedOn717_,
document0_1_.UpdatedOn as UpdatedOn717_,
document0_1_.DeletedOn as DeletedOn717_,
document0_1_.Deleted as Deleted717_,
document0_1_.Active as Active717_,
document0_1_.ActivatedOn as Activate7_717_,
document0_1_.DeactivatedOn as Deactiva8_717_,
document0_1_.Locked as Locked717_,
document0_1_.DateReceived as DateRec10_717_,
document0_1_.DateIssued as DateIssued717_,
document0_1_.CreateUserID as CreateU12_717_,
document0_1_.UpdateUserID as UpdateU13_717_,
document0_2_.CreatedOn as CreatedOn733_,
document0_2_.UpdatedOn as UpdatedOn733_,
document0_2_.DeletedOn as DeletedOn733_,
document0_2_.Deleted as Deleted733_,
document0_2_.Active as Active733_,
document0_2_.ActivatedOn as Activate7_733_,
document0_2_.DeactivatedOn as Deactiva8_733_,
document0_2_.Locked as Locked733_,
document0_3_.CreatedOn as CreatedOn739_,
document0_3_.UpdatedOn as UpdatedOn739_,
document0_3_.DeletedOn as DeletedOn739_,
document0_3_.Deleted as Deleted739_,
document0_3_.Active as Active739_,
document0_3_.ActivatedOn as Activate7_739_,
document0_3_.DeactivatedOn as Deactiva8_739_,
document0_3_.Locked as Locked739_,
document0_4_.CreatedOn as CreatedOn754_,
document0_4_.UpdatedOn as UpdatedOn754_,
document0_4_.DeletedOn as DeletedOn754_,
document0_4_.Deleted as Deleted754_,
document0_4_.Active as Active754_,
document0_4_.ActivatedOn as Activate7_754_,
document0_4_.DeactivatedOn as Deactiva8_754_,
document0_4_.Locked as Locked754_,
document0_5_.CreatedOn as CreatedOn755_,
document0_5_.UpdatedOn as UpdatedOn755_,
document0_5_.DeletedOn as DeletedOn755_,
document0_5_.Deleted as Deleted755_,
document0_5_.Active as Active755_,
document0_5_.ActivatedOn as Activate7_755_,
document0_5_.DeactivatedOn as Deactiva8_755_,
document0_5_.Locked as Locked755_,
document0_6_.CreatedOn as CreatedOn759_,
document0_6_.UpdatedOn as UpdatedOn759_,
document0_6_.DeletedOn as DeletedOn759_,
document0_6_.Deleted as Deleted759_,
document0_6_.Active as Active759_,
document0_6_.ActivatedOn as Activate7_759_,
document0_6_.DeactivatedOn as Deactiva8_759_,
document0_6_.Locked as Locked759_,
document0_7_.CreatedOn as CreatedOn773_,
document0_7_.UpdatedOn as UpdatedOn773_,
document0_7_.DeletedOn as DeletedOn773_,
document0_7_.Deleted as Deleted773_,
document0_7_.Active as Active773_,
document0_7_.ActivatedOn as Activate7_773_,
document0_7_.DeactivatedOn as Deactiva8_773_,
document0_7_.Locked as Locked773_,
document0_8_.CreatedOn as CreatedOn774_,
document0_8_.UpdatedOn as UpdatedOn774_,
document0_8_.DeletedOn as DeletedOn774_,
document0_8_.Deleted as Deleted774_,
document0_8_.Active as Active774_,
document0_8_.ActivatedOn as Activate7_774_,
document0_8_.DeactivatedOn as Deactiva8_774_,
document0_8_.Locked as Locked774_,
document0_9_.CreatedOn as CreatedOn779_,
document0_9_.UpdatedOn as UpdatedOn779_,
document0_9_.DeletedOn as DeletedOn779_,
document0_9_.Deleted as Deleted779_,
document0_9_.Active as Active779_,
document0_9_.ActivatedOn as Activate7_779_,
document0_9_.DeactivatedOn as Deactiva8_779_,
document0_9_.Locked as Locked779_,
document0_10_.CreatedOn as CreatedOn780_,
document0_10_.UpdatedOn as UpdatedOn780_,
document0_10_.DeletedOn as DeletedOn780_,
document0_10_.Deleted as Deleted780_,
document0_10_.Active as Active780_,
document0_10_.ActivatedOn as Activate7_780_,
document0_10_.DeactivatedOn as Deactiva8_780_,
document0_10_.Locked as Locked780_,
document0_11_.CreatedOn as CreatedOn781_,
document0_11_.UpdatedOn as UpdatedOn781_,
document0_11_.DeletedOn as DeletedOn781_,
document0_11_.Deleted as Deleted781_,
document0_11_.Active as Active781_,
document0_11_.ActivatedOn as Activate7_781_,
document0_11_.DeactivatedOn as Deactiva8_781_,
document0_11_.Locked as Locked781_,
document0_11_.ExpiryDate as ExpiryDate781_,
document0_11_.Number as Number781_,
document0_11_.CreateUserID as CreateU12_781_,
document0_11_.UpdateUserID as UpdateU13_781_,
document0_12_.CreatedOn as CreatedOn784_,
document0_12_.UpdatedOn as UpdatedOn784_,
document0_12_.DeletedOn as DeletedOn784_,
document0_12_.Deleted as Deleted784_,
document0_12_.Active as Active784_,
document0_12_.ActivatedOn as Activate7_784_,
document0_12_.DeactivatedOn as Deactiva8_784_,
document0_12_.Locked as Locked784_,
document0_12_.CreateUserID as CreateU10_784_,
document0_12_.UpdateUserID as UpdateU11_784_,
document0_12_.SurveyID as SurveyID784_,
document0_13_.CreatedOn as CreatedOn789_,
document0_13_.UpdatedOn as UpdatedOn789_,
document0_13_.DeletedOn as DeletedOn789_,
document0_13_.Deleted as Deleted789_,
document0_13_.Active as Active789_,
document0_13_.ActivatedOn as Activate7_789_,
document0_13_.DeactivatedOn as Deactiva8_789_,
document0_13_.Locked as Locked789_,
document0_14_.CreatedOn as CreatedOn790_,
document0_14_.UpdatedOn as UpdatedOn790_,
document0_14_.DeletedOn as DeletedOn790_,
document0_14_.Deleted as Deleted790_,
document0_14_.Active as Active790_,
document0_14_.ActivatedOn as Activate7_790_,
document0_14_.DeactivatedOn as Deactiva8_790_,
document0_14_.Locked as Locked790_,
document0_14_.aboriginal as aboriginal790_,
document0_14_.disability as disability790_,
document0_14_.minority as minority790_,
document0_14_.refuse as refuse790_,
document0_14_.CreateUserID as CreateU14_790_,
document0_14_.UpdateUserID as UpdateU15_790_,
document0_15_.CreatedOn as CreatedOn791_,
document0_15_.UpdatedOn as UpdatedOn791_,
document0_15_.DeletedOn as DeletedOn791_,
document0_15_.Deleted as Deleted791_,
document0_15_.Active as Active791_,
document0_15_.ActivatedOn as Activate7_791_,
document0_15_.DeactivatedOn as Deactiva8_791_,
document0_15_.Locked as Locked791_,
document0_15_.TypeOfTraining as TypeOfT10_791_,
document0_15_.Location as Location791_,
document0_15_.TrainerName as Trainer12_791_,
document0_15_.[Result] as Result13_791_,
document0_15_.TrainingDate as Trainin14_791_,
document0_15_.ExpiryDate as ExpiryDate791_,
document0_15_.CreateUserID as CreateU16_791_,
document0_15_.UpdateUserID as UpdateU17_791_,
document0_16_.CreatedOn as CreatedOn792_,
document0_16_.UpdatedOn as UpdatedOn792_,
document0_16_.DeletedOn as DeletedOn792_,
document0_16_.Deleted as Deleted792_,
document0_16_.Active as Active792_,
document0_16_.ActivatedOn as Activate7_792_,
document0_16_.DeactivatedOn as Deactiva8_792_,
document0_16_.Locked as Locked792_,
document0_16_.CreateUserID as CreateU10_792_,
document0_16_.UpdateUserID as UpdateU11_792_,
document0_17_.CreatedOn as CreatedOn793_,
document0_17_.UpdatedOn as UpdatedOn793_,
document0_17_.DeletedOn as DeletedOn793_,
document0_17_.Deleted as Deleted793_,
document0_17_.Active as Active793_,
document0_17_.ActivatedOn as Activate7_793_,
document0_17_.DeactivatedOn as Deactiva8_793_,
document0_17_.Locked as Locked793_,
document0_17_.Content as Content793_,
document0_17_.CreateUserID as CreateU11_793_,
document0_17_.UpdateUserID as UpdateU12_793_,
document0_18_.CreatedOn as CreatedOn795_,
document0_18_.UpdatedOn as UpdatedOn795_,
document0_18_.DeletedOn as DeletedOn795_,
document0_18_.Deleted as Deleted795_,
document0_18_.Active as Active795_,
document0_18_.ActivatedOn as Activate7_795_,
document0_18_.DeactivatedOn as Deactiva8_795_,
document0_18_.Locked as Locked795_,
document0_19_.CreatedOn as CreatedOn800_,
document0_19_.UpdatedOn as UpdatedOn800_,
document0_19_.DeletedOn as DeletedOn800_,
document0_19_.Deleted as Deleted800_,
document0_19_.Active as Active800_,
document0_19_.ActivatedOn as Activate7_800_,
document0_19_.DeactivatedOn as Deactiva8_800_,
document0_19_.Locked as Locked800_,
document0_20_.CreatedOn as CreatedOn802_,
document0_20_.UpdatedOn as UpdatedOn802_,
document0_20_.DeletedOn as DeletedOn802_,
document0_20_.Deleted as Deleted802_,
document0_20_.Active as Active802_,
document0_20_.ActivatedOn as Activate7_802_,
document0_20_.DeactivatedOn as Deactiva8_802_,
document0_20_.Locked as Locked802_,
document0_20_.StartDate as StartDate802_,
document0_20_.EndDate as EndDate802_,
document0_21_.CreatedOn as CreatedOn807_,
document0_21_.UpdatedOn as UpdatedOn807_,
document0_21_.DeletedOn as DeletedOn807_,
document0_21_.Deleted as Deleted807_,
document0_21_.Active as Active807_,
document0_21_.ActivatedOn as Activate7_807_,
document0_21_.DeactivatedOn as Deactiva8_807_,
document0_21_.Locked as Locked807_,
document0_21_.CreateUserID as CreateU18_807_,
document0_21_.UpdateUserID as UpdateU19_807_,
document0_21_.EducationLevelTypeID as Educati21_807_,
document0_22_.CreatedOn as CreatedOn808_,
document0_22_.UpdatedOn as UpdatedOn808_,
document0_22_.DeletedOn as DeletedOn808_,
document0_22_.Deleted as Deleted808_,
document0_22_.Active as Active808_,
document0_22_.ActivatedOn as Activate7_808_,
document0_22_.DeactivatedOn as Deactiva8_808_,
document0_22_.Locked as Locked808_,
document0_22_.CreateUserID as CreateU10_808_,
document0_22_.UpdateUserID as UpdateU11_808_,
document0_23_.CreatedOn as CreatedOn809_,
document0_23_.UpdatedOn as UpdatedOn809_,
document0_23_.DeletedOn as DeletedOn809_,
document0_23_.Deleted as Deleted809_,
document0_23_.Active as Active809_,
document0_23_.ActivatedOn as Activate7_809_,
document0_23_.DeactivatedOn as Deactiva8_809_,
document0_23_.Locked as Locked809_,
document0_24_.CreatedOn as CreatedOn810_,
document0_24_.UpdatedOn as UpdatedOn810_,
document0_24_.DeletedOn as DeletedOn810_,
document0_24_.Deleted as Deleted810_,
document0_24_.Active as Active810_,
document0_24_.ActivatedOn as Activate7_810_,
document0_24_.DeactivatedOn as Deactiva8_810_,
document0_24_.Locked as Locked810_,
document0_24_.CreateUserID as CreateU10_810_,
document0_24_.UpdateUserID as UpdateU11_810_,
document0_25_.CreatedOn as CreatedOn811_,
document0_25_.UpdatedOn as UpdatedOn811_,
document0_25_.DeletedOn as DeletedOn811_,
document0_25_.Deleted as Deleted811_,
document0_25_.Active as Active811_,
document0_25_.ActivatedOn as Activate7_811_,
document0_25_.DeactivatedOn as Deactiva8_811_,
document0_25_.Locked as Locked811_,
document0_26_.CreatedOn as CreatedOn815_,
document0_26_.UpdatedOn as UpdatedOn815_,
document0_26_.DeletedOn as DeletedOn815_,
document0_26_.Deleted as Deleted815_,
document0_26_.Active as Active815_,
document0_26_.ActivatedOn as Activate7_815_,
document0_26_.DeactivatedOn as Deactiva8_815_,
document0_26_.Locked as Locked815_,
document0_27_.CreatedOn as CreatedOn816_,
document0_27_.UpdatedOn as UpdatedOn816_,
document0_27_.DeletedOn as DeletedOn816_,
document0_27_.Deleted as Deleted816_,
document0_27_.Active as Active816_,
document0_27_.ActivatedOn as Activate7_816_,
document0_27_.DeactivatedOn as Deactiva8_816_,
document0_27_.Locked as Locked816_,
document0_27_.DateReceived as DateRec10_816_,
document0_27_.DateIssued as DateIssued816_,
document0_27_.CreateUserID as CreateU12_816_,
document0_27_.UpdateUserID as UpdateU13_816_,
document0_28_.CreatedOn as CreatedOn819_,
document0_28_.UpdatedOn as UpdatedOn819_,
document0_28_.DeletedOn as DeletedOn819_,
document0_28_.Deleted as Deleted819_,
document0_28_.Active as Active819_,
document0_28_.ActivatedOn as Activate7_819_,
document0_28_.DeactivatedOn as Deactiva8_819_,
document0_28_.Locked as Locked819_,
document0_28_.LicenceDocumentNumber as Licence10_819_,
document0_28_.DemeritPoints as Demerit11_819_,
document0_28_.MeritPoints as MeritPo12_819_,
document0_28_.ExpiryDate as ExpiryDate819_,
document0_28_.CreateUserID as CreateU14_819_,
document0_28_.UpdateUserID as UpdateU15_819_,
document0_28_.LicenceDocumentStatusTypeID as Licence16_819_,
document0_28_.StateProvinceID as StatePr17_819_,
document0_29_.CreatedOn as CreatedOn820_,
document0_29_.UpdatedOn as UpdatedOn820_,
document0_29_.DeletedOn as DeletedOn820_,
document0_29_.Deleted as Deleted820_,
document0_29_.Active as Active820_,
document0_29_.ActivatedOn as Activate7_820_,
document0_29_.DeactivatedOn as Deactiva8_820_,
document0_29_.Locked as Locked820_,
document0_29_.CreateUserID as CreateU10_820_,
document0_29_.UpdateUserID as UpdateU11_820_,
document0_30_.CreatedOn as CreatedOn821_,
document0_30_.UpdatedOn as UpdatedOn821_,
document0_30_.DeletedOn as DeletedOn821_,
document0_30_.Deleted as Deleted821_,
document0_30_.Active as Active821_,
document0_30_.ActivatedOn as Activate7_821_,
document0_30_.DeactivatedOn as Deactiva8_821_,
document0_30_.Locked as Locked821_,
document0_30_.ExpiryDate as ExpiryDate821_,
document0_30_.LicenceNumber as Licence11_821_,
document0_30_.CreateUserID as CreateU12_821_,
document0_30_.UpdateUserID as UpdateU13_821_,
document0_30_.StateProvinceID as StatePr14_821_,
document0_31_.CreatedOn as CreatedOn822_,
document0_31_.UpdatedOn as UpdatedOn822_,
document0_31_.DeletedOn as DeletedOn822_,
document0_31_.Deleted as Deleted822_,
document0_31_.Active as Active822_,
document0_31_.ActivatedOn as Activate7_822_,
document0_31_.DeactivatedOn as Deactiva8_822_,
document0_31_.Locked as Locked822_,
document0_32_.CreatedOn as CreatedOn823_,
document0_32_.UpdatedOn as UpdatedOn823_,
document0_32_.DeletedOn as DeletedOn823_,
document0_32_.Deleted as Deleted823_,
document0_32_.Active as Active823_,
document0_32_.ActivatedOn as Activate7_823_,
document0_32_.DeactivatedOn as Deactiva8_823_,
document0_32_.Locked as Locked823_,
document0_33_.CreatedOn as CreatedOn824_,
document0_33_.UpdatedOn as UpdatedOn824_,
document0_33_.DeletedOn as DeletedOn824_,
document0_33_.Deleted as Deleted824_,
document0_33_.Active as Active824_,
document0_33_.ActivatedOn as Activate7_824_,
document0_33_.DeactivatedOn as Deactiva8_824_,
document0_33_.Locked as Locked824_,
document0_33_.CreateUserID as CreateU10_824_,
document0_33_.UpdateUserID as UpdateU11_824_,
document0_34_.CreatedOn as CreatedOn825_,
document0_34_.UpdatedOn as UpdatedOn825_,
document0_34_.DeletedOn as DeletedOn825_,
document0_34_.Deleted as Deleted825_,
document0_34_.Active as Active825_,
document0_34_.ActivatedOn as Activate7_825_,
document0_34_.DeactivatedOn as Deactiva8_825_,
document0_34_.Locked as Locked825_,
document0_35_.CreatedOn as CreatedOn826_,
document0_35_.UpdatedOn as UpdatedOn826_,
document0_35_.DeletedOn as DeletedOn826_,
document0_35_.Deleted as Deleted826_,
document0_35_.Active as Active826_,
document0_35_.ActivatedOn as Activate7_826_,
document0_35_.DeactivatedOn as Deactiva8_826_,
document0_35_.Locked as Locked826_,
document0_35_.ExpiryDate as ExpiryDate826_,
document0_35_.CreateUserID as CreateU11_826_,
document0_35_.UpdateUserID as UpdateU12_826_,
document0_36_.CreatedOn as CreatedOn827_,
document0_36_.UpdatedOn as UpdatedOn827_,
document0_36_.DeletedOn as DeletedOn827_,
document0_36_.Deleted as Deleted827_,
document0_36_.Active as Active827_,
document0_36_.ActivatedOn as Activate7_827_,
document0_36_.DeactivatedOn as Deactiva8_827_,
document0_36_.Locked as Locked827_,
document0_36_.ExpiryDate as ExpiryDate827_,
document0_36_.CreateUserID as CreateU11_827_,
document0_36_.UpdateUserID as UpdateU12_827_,
document0_37_.CreatedOn as CreatedOn829_,
document0_37_.UpdatedOn as UpdatedOn829_,
document0_37_.DeletedOn as DeletedOn829_,
document0_37_.Deleted as Deleted829_,
document0_37_.Active as Active829_,
document0_37_.ActivatedOn as Activate7_829_,
document0_37_.DeactivatedOn as Deactiva8_829_,
document0_37_.Locked as Locked829_,
document0_37_.CheckDate as CheckDate829_,
document0_37_.CreateUserID as CreateU11_829_,
document0_37_.UpdateUserID as UpdateU12_829_,
document0_38_.CreatedOn as CreatedOn830_,
document0_38_.UpdatedOn as UpdatedOn830_,
document0_38_.DeletedOn as DeletedOn830_,
document0_38_.Deleted as Deleted830_,
document0_38_.Active as Active830_,
document0_38_.ActivatedOn as Activate7_830_,
document0_38_.DeactivatedOn as Deactiva8_830_,
document0_38_.Locked as Locked830_,
document0_39_.CreatedOn as CreatedOn831_,
document0_39_.UpdatedOn as UpdatedOn831_,
document0_39_.DeletedOn as DeletedOn831_,
document0_39_.Deleted as Deleted831_,
document0_39_.Active as Active831_,
document0_39_.ActivatedOn as Activate7_831_,
document0_39_.DeactivatedOn as Deactiva8_831_,
document0_39_.Locked as Locked831_,
document0_40_.CreatedOn as CreatedOn832_,
document0_40_.UpdatedOn as UpdatedOn832_,
document0_40_.DeletedOn as DeletedOn832_,
document0_40_.Deleted as Deleted832_,
document0_40_.Active as Active832_,
document0_40_.ActivatedOn as Activate7_832_,
document0_40_.DeactivatedOn as Deactiva8_832_,
document0_40_.Locked as Locked832_,
document0_41_.CreatedOn as CreatedOn833_,
document0_41_.UpdatedOn as UpdatedOn833_,
document0_41_.DeletedOn as DeletedOn833_,
document0_41_.Deleted as Deleted833_,
document0_41_.Active as Active833_,
document0_41_.ActivatedOn as Activate7_833_,
document0_41_.DeactivatedOn as Deactiva8_833_,
document0_41_.Locked as Locked833_,
document0_41_.CreateUserID as CreateU10_833_,
document0_41_.UpdateUserID as UpdateU11_833_,
document0_.Subtype as Subtype715_
from
Document document0_
left outer join
CustomDocument1 document0_1_
on document0_.ID=document0_1_.DocumentID
left outer join
CustomDocument2 document0_2_
on document0_.ID=document0_2_.DocumentID
left outer join
CustomDocument3 document0_3_
on document0_.ID=document0_3_.DocumentID
left outer join
CustomDocument4 document0_4_
on document0_.ID=document0_4_.DocumentID
left outer join
CustomDocument5 document0_5_
on document0_.ID=document0_5_.DocumentID
left outer join
CustomDocument6 document0_6_
on document0_.ID=document0_6_.DocumentID
left outer join
CustomDocument7 document0_7_
on document0_.ID=document0_7_.DocumentID
left outer join
CustomDocument8 document0_8_
on document0_.ID=document0_8_.DocumentID
left outer join
CustomDocument9 document0_9_
on document0_.ID=document0_9_.DocumentID
left outer join
CustomDocument10 document0_10_
on document0_.ID=document0_10_.DocumentID
left outer join
CustomDocument11 document0_11_
on document0_.ID=document0_11_.DocumentID
left outer join
CustomDocument12 document0_12_
on document0_.ID=document0_12_.DocumentID
left outer join
CustomDocument13 document0_13_
on document0_.ID=document0_13_.DocumentID
left outer join
CustomDocument14 document0_14_
on document0_.ID=document0_14_.DocumentID
left outer join
CustomDocument15 document0_15_
on document0_.ID=document0_15_.DocumentID
left outer join
CustomDocument16 document0_16_
on document0_.ID=document0_16_.DocumentID
left outer join
CustomDocument17 document0_17_
on document0_.ID=document0_17_.DocumentID
left outer join
CustomDocument18 document0_18_
on document0_.ID=document0_18_.DocumentID
left outer join
CustomDocument19 document0_19_
on document0_.ID=document0_19_.DocumentID
left outer join
CustomDocument20 document0_20_
on document0_.ID=document0_20_.DocumentID
left outer join
CustomDocument21 document0_21_
on document0_.ID=document0_21_.DocumentID
left outer join
CustomDocument22 document0_22_
on document0_.ID=document0_22_.DocumentID
left outer join
CustomDocument23 document0_23_
on document0_.ID=document0_23_.DocumentID
left outer join
CustomDocument24 document0_24_
on document0_.ID=document0_24_.DocumentID
left outer join
CustomDocument25 document0_25_
on document0_.ID=document0_25_.DocumentID
left outer join
CustomDocument26 document0_26_
on document0_.ID=document0_26_.DocumentID
left outer join
CustomDocument27 document0_27_
on document0_.ID=document0_27_.DocumentID
left outer join
CustomDocument28 document0_28_
on document0_.ID=document0_28_.DocumentID
left outer join
CustomDocument29 document0_29_
on document0_.ID=document0_29_.DocumentID
left outer join
CustomDocument30 document0_30_
on document0_.ID=document0_30_.DocumentID
left outer join
CustomDocument31 document0_31_
on document0_.ID=document0_31_.DocumentID
left outer join
CustomDocument32 document0_32_
on document0_.ID=document0_32_.DocumentID
left outer join
CustomDocument33 document0_33_
on document0_.ID=document0_33_.DocumentID
left outer join
CustomDocument34 document0_34_
on document0_.ID=document0_34_.DocumentID
left outer join
CustomDocument35 document0_35_
on document0_.ID=document0_35_.DocumentID
left outer join
CustomDocument36 document0_36_
on document0_.ID=document0_36_.DocumentID
left outer join
CustomDocument37 document0_37_
on document0_.ID=document0_37_.DocumentID
left outer join
CustomDocument38 document0_38_
on document0_.ID=document0_38_.DocumentID
left outer join
CustomDocument39 document0_39_
on document0_.ID=document0_39_.DocumentID
left outer join
CustomDocument40 document0_40_
on document0_.ID=document0_40_.DocumentID
left outer join
CustomDocument41 document0_41_
on document0_.ID=document0_41_.DocumentID
where
document0_.DocumentTypeID=?
and document0_.Locked=?
Thanks to #TabAlleman, #Ionic et al. The comments helped me realize that it is the calculation of the execution plan that is sucking up so many resources. This understanding led me to find this SO question asking about execution plans taking a long time to generate in SQL Server 2014.
I should have mentioned that we are using SQL Server 2014 as it turns out this version introduced an aggressive new query optimizer that has trouble with the query in question. If I set the database compatibility to SQL Server 2012, the execution plan is generated immediately.
I may still log a bug in SQL Connect as this query may represent an edge case that needs looking into.
Thanks all.
Related
MS SQl show empty results
Below query is matching if the partner code below is having asset code, but if no match its not showing it. i need even if the partner_code is not having asset code to show any result null or 0 select Asset_code, partner_code from Asset where PARTNER_CODE in ('28800330', '28800332', '28800014', '41900139', '28800210', '29200298', '29200149', '29200259', '29200086', '29400280', '29000314', '29000224', '29600306', '29100045', '29800530', '29800543', '29900474', '29700298', '27400112', '27400648', '27400668', '85400058', '27300472', '53200002', '27800221', '27800039', '27200013')
spring data select query performance problems when using IN clause with a collection of objects
I am experiencing a weird behavior using select query IN clause with a collection (I am using MSSQL on Azure). I have the following code: final Query query = em.createNativeQuery("select p.id as productId, p.external_id as externalId from products p where p.id in (:ids)"); // the ids list is of size 750 query.setParameter("ids", ids); query.getResultList(); This code takes about 4 minutes to run, however running the query directly from the MSSQL client, it takes 1-2 seconds. I was suspecting the in clause and I modified the code: final String queryString = "select p.id as productId, p.external_id as externalId from products p where p.id in (%s)"; String inClause = ...; // generate a string of type 'id1', 'id2',...'id750' final Query query = em.createNativeQuery(String.format(queryString, inClause)); query.getResultList(); The second version takes only 10 seconds to run. Do you know any specific known problem running in clause queries? Can you suggest any solution how to get this working? UPDATE: I found out that the problem is actually happening with parameterized query, I tried to use a jdbc template and use my own wrapper to iterate over the results set. I iterated over the results set only printed the index, I could see that after about 590 results the results set hangs for about 3-4 minutes and then continues and finishes. UPDATE: the id column which is the PK, is a char[36] column I can see the query generated on Azure MSSSQL: (#P749 nvarchar(4000),#P748 nvarchar(4000),#P747 nvarchar(4000),#P746 nvarchar(4000),#P745 nvarchar(4000),#P744 nvarchar(4000),#P743 nvarchar(4000),#P742 nvarchar(4000),#P741 nvarchar(4000),#P740 nvarchar(4000),#P739 nvarchar(4000),#P738 nvarchar(4000),#P737 nvarchar(4000),#P736 nvarchar(4000),#P735 nvarchar(4000),#P734 nvarchar(4000),#P733 nvarchar(4000),#P732 nvarchar(4000),#P731 nvarchar(4000),#P730 nvarchar(4000),#P729 nvarchar(4000),#P728 nvarchar(4000),#P727 nvarchar(4000),#P726 nvarchar(4000),#P725 nvarchar(4000),#P724 nvarchar(4000),#P723 nvarchar(4000),#P722 nvarchar(4000),#P721 nvarchar(4000),#P720 nvarchar(4000),#P719 nvarchar(4000),#P718 nvarchar(4000),#P717 nvarchar(4000),#P716 nvarchar(4000),#P715 nvarchar(4000),#P714 nvarchar(4000),#P713 nvarchar(4000),#P712 nvarchar(4000),#P711 nvarchar(4000),#P710 nvarchar(4000),#P709 nvarchar(4000),#P708 nvarchar(4000),#P707 nvarchar(4000),#P706 nvarchar(4000),#P705 nvarchar(4000),#P704 nvarchar(4000),#P703 nvarchar(4000),#P702 nvarchar(4000),#P701 nvarchar(4000),#P700 nvarchar(4000),#P699 nvarchar(4000),#P698 nvarchar(4000),#P697 nvarchar(4000),#P696 nvarchar(4000),#P695 nvarchar(4000),#P694 nvarchar(4000),#P693 nvarchar(4000),#P692 nvarchar(4000),#P691 nvarchar(4000),#P690 nvarchar(4000),#P689 nvarchar(4000),#P688 nvarchar(4000),#P687 nvarchar(4000),#P686 nvarchar(4000),#P685 nvarchar(4000),#P684 nvarchar(4000),#P683 nvarchar(4000),#P682 nvarchar(4000),#P681 nvarchar(4000),#P680 nvarchar(4000),#P679 nvarchar(4000),#P678 nvarchar(4000),#P677 nvarchar(4000),#P676 nvarchar(4000),#P675 nvarchar(4000),#P674 nvarchar(4000),#P673 nvarchar(4000),#P672 nvarchar(4000),#P671 nvarchar(4000),#P670 nvarchar(4000),#P669 nvarchar(4000),#P668 nvarchar(4000),#P667 nvarchar(4000),#P666 nvarchar(4000),#P665 nvarchar(4000),#P664 nvarchar(4000),#P663 nvarchar(4000),#P662 nvarchar(4000),#P661 nvarchar(4000),#P660 nvarchar(4000),#P659 nvarchar(4000),#P658 nvarchar(4000),#P657 nvarchar(4000),#P656 nvarchar(4000),#P655 nvarchar(4000),#P654 nvarchar(4000),#P653 nvarchar(4000),#P652 nvarchar(4000),#P651 nvarchar(4000),#P650 nvarchar(4000),#P649 nvarchar(4000),#P648 nvarchar(4000),#P647 nvarchar(4000),#P646 nvarchar(4000),#P645 nvarchar(4000),#P644 nvarchar(4000),#P643 nvarchar(4000),#P642 nvarchar(4000),#P641 nvarchar(4000),#P640 nvarchar(4000),#P639 nvarchar(4000),#P638 nvarchar(4000),#P637 nvarchar(4000),#P636 nvarchar(4000),#P635 nvarchar(4000),#P634 nvarchar(4000),#P633 nvarchar(4000),#P632 nvarchar(4000),#P631 nvarchar(4000),#P630 nvarchar(4000),#P629 nvarchar(4000),#P628 nvarchar(4000),#P627 nvarchar(4000),#P626 nvarchar(4000),#P625 nvarchar(4000),#P624 nvarchar(4000),#P623 nvarchar(4000),#P622 nvarchar(4000),#P621 nvarchar(4000),#P620 nvarchar(4000),#P619 nvarchar(4000),#P618 nvarchar(4000),#P617 nvarchar(4000),#P616 nvarchar(4000),#P615 nvarchar(4000),#P614 nvarchar(4000),#P613 nvarchar(4000),#P612 nvarchar(4000),#P611 nvarchar(4000),#P610 nvarchar(4000),#P609 nvarchar(4000),#P608 nvarchar(4000),#P607 nvarchar(4000),#P606 nvarchar(4000),#P605 nvarchar(4000),#P604 nvarchar(4000),#P603 nvarchar(4000),#P602 nvarchar(4000),#P601 nvarchar(4000),#P600 nvarchar(4000),#P599 nvarchar(4000),#P598 nvarchar(4000),#P597 nvarchar(4000),#P596 nvarchar(4000),#P595 nvarchar(4000),#P594 nvarchar(4000),#P593 nvarchar(4000),#P592 nvarchar(4000),#P591 nvarchar(4000),#P590 nvarchar(4000),#P589 nvarchar(4000),#P588 nvarchar(4000),#P587 nvarchar(4000),#P586 nvarchar(4000),#P585 nvarchar(4000),#P584 nvarchar(4000),#P583 nvarchar(4000),#P582 nvarchar(4000),#P581 nvarchar(4000),#P580 nvarchar(4000),#P579 nvarchar(4000),#P578 nvarchar(4000),#P577 nvarchar(4000),#P576 nvarchar(4000),#P575 nvarchar(4000),#P574 nvarchar(4000),#P573 nvarchar(4000),#P572 nvarchar(4000),#P571 nvarchar(4000),#P570 nvarchar(4000),#P569 nvarchar(4000),#P568 nvarchar(4000),#P567 nvarchar(4000),#P566 nvarchar(4000),#P565 nvarchar(4000),#P564 nvarchar(4000),#P563 nvarchar(4000),#P562 nvarchar(4000),#P561 nvarchar(4000),#P560 nvarchar(4000),#P559 nvarchar(4000),#P558 nvarchar(4000),#P557 nvarchar(4000),#P556 nvarchar(4000),#P555 nvarchar(4000),#P554 nvarchar(4000),#P553 nvarchar(4000),#P552 nvarchar(4000),#P551 nvarchar(4000),#P550 nvarchar(4000),#P549 nvarchar(4000),#P548 nvarchar(4000),#P547 nvarchar(4000),#P546 nvarchar(4000),#P545 nvarchar(4000),#P544 nvarchar(4000),#P543 nvarchar(4000),#P542 nvarchar(4000),#P541 nvarchar(4000),#P540 nvarchar(4000),#P539 nvarchar(4000),#P538 nvarchar(4000),#P537 nvarchar(4000),#P536 nvarchar(4000),#P535 nvarchar(4000),#P534 nvarchar(4000),#P533 nvarchar(4000),#P532 nvarchar(4000),#P531 nvarchar(4000),#P530 nvarchar(4000),#P529 nvarchar(4000),#P528 nvarchar(4000),#P527 nvarchar(4000),#P526 nvarchar(4000),#P525 nvarchar(4000),#P524 nvarchar(4000),#P523 nvarchar(4000),#P522 nvarchar(4000),#P521 nvarchar(4000),#P520 nvarchar(4000),#P519 nvarchar(4000),#P518 nvarchar(4000),#P517 nvarchar(4000),#P516 nvarchar(4000),#P515 nvarchar(4000),#P514 nvarchar(4000),#P513 nvarchar(4000),#P512 nvarchar(4000),#P511 nvarchar(4000),#P510 nvarchar(4000),#P509 nvarchar(4000),#P508 nvarchar(4000),#P507 nvarchar(4000),#P506 nvarchar(4000),#P505 nvarchar(4000),#P504 nvarchar(4000),#P503 nvarchar(4000),#P502 nvarchar(4000),#P501 nvarchar(4000),#P500 nvarchar(4000),#P499 nvarchar(4000),#P498 nvarchar(4000),#P497 nvarchar(4000),#P496 nvarchar(4000),#P495 nvarchar(4000),#P494 nvarchar(4000),#P493 nvarchar(4000),#P492 nvarchar(4000),#P491 nvarchar(4000),#P490 nvarchar(4000),#P489 nvarchar(4000),#P488 nvarchar(4000),#P487 nvarchar(4000),#P486 nvarchar(4000),#P485 nvarchar(4000),#P484 nvarchar(4000),#P483 nvarchar(4000),#P482 nvarchar(4000),#P481 nvarchar(4000),#P480 nvarchar(4000),#P479 nvarchar(4000),#P478 nvarchar(4000),#P477 nvarchar(4000),#P476 nvarchar(4000),#P475 nvarchar(4000),#P474 nvarchar(4000),#P473 nvarchar(4000),#P472 nvarchar(4000),#P471 nvarchar(4000),#P470 nvarchar(4000),#P469 nvarchar(4000),#P468 nvarchar(4000),#P467 nvarchar(4000),#P466 nvarchar(4000),#P465 nvarchar(4000),#P464 nvarchar(4000),#P463 nvarchar(4000),#P462 nvarchar(4000),#P461 nvarchar(4000),#P460 nvarchar(4000),#P459 nvarchar(4000),#P458 nvarchar(4000),#P457 nvarchar(4000),#P456 nvarchar(4000),#P455 nvarchar(4000),#P454 nvarchar(4000),#P453 nvarchar(4000),#P452 nvarchar(4000),#P451 nvarchar(4000),#P450 nvarchar(4000),#P449 nvarchar(4000),#P448 nvarchar(4000),#P447 nvarchar(4000),#P446 nvarchar(4000),#P445 nvarchar(4000),#P444 nvarchar(4000),#P443 nvarchar(4000),#P442 nvarchar(4000),#P441 nvarchar(4000),#P440 nvarchar(4000),#P439 nvarchar(4000),#P438 nvarchar(4000),#P437 nvarchar(4000),#P436 nvarchar(4000),#P435 nvarchar(4000),#P434 nvarchar(4000),#P433 nvarchar(4000),#P432 nvarchar(4000),#P431 nvarchar(4000),#P430 nvarchar(4000),#P429 nvarchar(4000),#P428 nvarchar(4000),#P427 nvarchar(4000),#P426 nvarchar(4000),#P425 nvarchar(4000),#P424 nvarchar(4000),#P423 nvarchar(4000),#P422 nvarchar(4000),#P421 nvarchar(4000),#P420 nvarchar(4000),#P419 nvarchar(4000),#P418 nvarchar(4000),#P417 nvarchar(4000),#P416 nvarchar(4000),#P415 nvarchar(4000),#P414 nvarchar(4000),#P413 nvarchar(4000),#P412 nvarchar(4000),#P411 nvarchar(4000),#P410 nvarchar(4000),#P409 nvarchar(4000),#P408 nvarchar(4000),#P407 nvarchar(4000),#P406 nvarchar(4000),#P405 nvarchar(4000),#P404 nvarchar(4000),#P403 nvarchar(4000),#P402 nvarchar(4000),#P401 nvarchar(4000),#P400 nvarchar(4000),#P399 nvarchar(4000),#P398 nvarchar(4000),#P397 nvarchar(4000),#P396 nvarchar(4000),#P395 nvarchar(4000),#P394 nvarchar(4000),#P393 nvarchar(4000),#P392 nvarchar(4000),#P391 nvarchar(4000),#P390 nvarchar(4000),#P389 nvarchar(4000),#P388 nvarchar(4000),#P387 nvarchar(4000),#P386 nvarchar(4000),#P385 nvarchar(4000),#P384 nvarchar(4000),#P383 nvarchar(4000),#P382 nvarchar(4000),#P381 nvarchar(4000),#P380 nvarchar(4000),#P379 nvarchar(4000),#P378 nvarchar(4000),#P377 nvarchar(4000),#P376 nvarchar(4000),#P375 nvarchar(4000),#P374 nvarchar(4000),#P373 nvarchar(4000),#P372 nvarchar(4000),#P371 nvarchar(4000),#P370 nvarchar(4000),#P369 nvarchar(4000),#P368 nvarchar(4000),#P367 nvarchar(4000),#P366 nvarchar(4000),#P365 nvarchar(4000),#P364 nvarchar(4000),#P363 nvarchar(4000),#P362 nvarchar(4000),#P361 nvarchar(4000),#P360 nvarchar(4000),#P359 nvarchar(4000),#P358 nvarchar(4000),#P357 nvarchar(4000),#P356 nvarchar(4000),#P355 nvarchar(4000),#P354 nvarchar(4000),#P353 nvarchar(4000),#P352 nvarchar(4000),#P351 nvarchar(4000),#P350 nvarchar(4000),#P349 nvarchar(4000),#P348 nvarchar(4000),#P347 nvarchar(4000),#P346 nvarchar(4000),#P345 nvarchar(4000),#P344 nvarchar(4000),#P343 nvarchar(4000),#P342 nvarchar(4000),#P341 nvarchar(4000),#P340 nvarchar(4000),#P339 nvarchar(4000),#P338 nvarchar(4000),#P337 nvarchar(4000),#P336 nvarchar(4000),#P335 nvarchar(4000),#P334 nvarchar(4000),#P333 nvarchar(4000),#P332 nvarchar(4000),#P331 nvarchar(4000),#P330 nvarchar(4000),#P329 nvarchar(4000),#P328 nvarchar(4000),#P327 nvarchar(4000),#P326 nvarchar(4000),#P325 nvarchar(4000),#P324 nvarchar(4000),#P323 nvarchar(4000),#P322 nvarchar(4000),#P321 nvarchar(4000),#P320 nvarchar(4000),#P319 nvarchar(4000),#P318 nvarchar(4000),#P317 nvarchar(4000),#P316 nvarchar(4000),#P315 nvarchar(4000),#P314 nvarchar(4000),#P313 nvarchar(4000),#P312 nvarchar(4000),#P311 nvarchar(4000),#P310 nvarchar(4000),#P309 nvarchar(4000),#P308 nvarchar(4000),#P307 nvarchar(4000),#P306 nvarchar(4000),#P305 nvarchar(4000),#P304 nvarchar(4000),#P303 nvarchar(4000),#P302 nvarchar(4000),#P301 nvarchar(4000),#P300 nvarchar(4000),#P299 nvarchar(4000),#P298 nvarchar(4000),#P297 nvarchar(4000),#P296 nvarchar(4000),#P295 nvarchar(4000),#P294 nvarchar(4000),#P293 nvarchar(4000),#P292 nvarchar(4000),#P291 nvarchar(4000),#P290 nvarchar(4000),#P289 nvarchar(4000),#P288 nvarchar(4000),#P287 nvarchar(4000),#P286 nvarchar(4000),#P285 nvarchar(4000),#P284 nvarchar(4000),#P283 nvarchar(4000),#P282 nvarchar(4000),#P281 nvarchar(4000),#P280 nvarchar(4000),#P279 nvarchar(4000),#P278 nvarchar(4000),#P277 nvarchar(4000),#P276 nvarchar(4000),#P275 nvarchar(4000),#P274 nvarchar(4000),#P273 nvarchar(4000),#P272 nvarchar(4000),#P271 nvarchar(4000),#P270 nvarchar(4000),#P269 nvarchar(4000),#P268 nvarchar(4000),#P267 nvarchar(4000),#P266 nvarchar(4000),#P265 nvarchar(4000),#P264 nvarchar(4000),#P263 nvarchar(4000),#P262 nvarchar(4000),#P261 nvarchar(4000),#P260 nvarchar(4000),#P259 nvarchar(4000),#P258 nvarchar(4000),#P257 nvarchar(4000),#P256 nvarchar(4000),#P255 nvarchar(4000),#P254 nvarchar(4000),#P253 nvarchar(4000),#P252 nvarchar(4000),#P251 nvarchar(4000),#P250 nvarchar(4000),#P249 nvarchar(4000),#P248 nvarchar(4000),#P247 nvarchar(4000),#P246 nvarchar(4000),#P245 nvarchar(4000),#P244 nvarchar(4000),#P243 nvarchar(4000),#P242 nvarchar(4000),#P241 nvarchar(4000),#P240 nvarchar(4000),#P239 nvarchar(4000),#P238 nvarchar(4000),#P237 nvarchar(4000),#P236 nvarchar(4000),#P235 nvarchar(4000),#P234 nvarchar(4000),#P233 nvarchar(4000),#P232 nvarchar(4000),#P231 nvarchar(4000),#P230 nvarchar(4000),#P229 nvarchar(4000),#P228 nvarchar(4000),#P227 nvarchar(4000),#P226 nvarchar(4000),#P225 nvarchar(4000),#P224 nvarchar(4000),#P223 nvarchar(4000),#P222 nvarchar(4000),#P221 nvarchar(4000),#P220 nvarchar(4000),#P219 nvarchar(4000),#P218 nvarchar(4000),#P217 nvarchar(4000),#P216 nvarchar(4000),#P215 nvarchar(4000),#P214 nvarchar(4000),#P213 nvarchar(4000),#P212 nvarchar(4000),#P211 nvarchar(4000),#P210 nvarchar(4000),#P209 nvarchar(4000),#P208 nvarchar(4000),#P207 nvarchar(4000),#P206 nvarchar(4000),#P205 nvarchar(4000),#P204 nvarchar(4000),#P203 nvarchar(4000),#P202 nvarchar(4000),#P201 nvarchar(4000),#P200 nvarchar(4000),#P199 nvarchar(4000),#P198 nvarchar(4000),#P197 nvarchar(4000),#P196 nvarchar(4000),#P195 nvarchar(4000),#P194 nvarchar(4000),#P193 nvarchar(4000),#P192 nvarchar(4000),#P191 nvarchar(4000),#P190 nvarchar(4000),#P189 nvarchar(4000),#P188 nvarchar(4000),#P187 nvarchar(4000),#P186 nvarchar(4000),#P185 nvarchar(4000),#P184 nvarchar(4000),#P183 nvarchar(4000),#P182 nvarchar(4000),#P181 nvarchar(4000),#P180 nvarchar(4000),#P179 nvarchar(4000),#P178 nvarchar(4000),#P177 nvarchar(4000),#P176 nvarchar(4000),#P175 nvarchar(4000),#P174 nvarchar(4000),#P173 nvarchar(4000),#P172 nvarchar(4000),#P171 nvarchar(4000),#P170 nvarchar(4000),#P169 nvarchar(4000),#P168 nvarchar(4000),#P167 nvarchar(4000),#P166 nvarchar(4000),#P165 nvarchar(4000),#P164 nvarchar(4000),#P163 nvarchar(4000),#P162 nvarchar(4000),#P161 nvarchar(4000),#P160 nvarchar(4000),#P159 nvarchar(4000),#P158 nvarchar(4000),#P157 nvarchar(4000),#P156 nvarchar(4000),#P155 nvarchar(4000),#P154 nvarchar(4000),#P153 nvarchar(4000),#P152 nvarchar(4000),#P151 nvarchar(4000),#P150 nvarchar(4000),#P149 nvarchar(4000),#P148 nvarchar(4000),#P147 nvarchar(4000),#P146 nvarchar(4000),#P145 nvarchar(4000),#P144 nvarchar(4000),#P143 nvarchar(4000),#P142 nvarchar(4000),#P141 nvarchar(4000),#P140 nvarchar(4000),#P139 nvarchar(4000),#P138 nvarchar(4000),#P137 nvarchar(4000),#P136 nvarchar(4000),#P135 nvarchar(4000),#P134 nvarchar(4000),#P133 nvarchar(4000),#P132 nvarchar(4000),#P131 nvarchar(4000),#P130 nvarchar(4000),#P129 nvarchar(4000),#P128 nvarchar(4000),#P127 nvarchar(4000),#P126 nvarchar(4000),#P125 nvarchar(4000),#P124 nvarchar(4000),#P123 nvarchar(4000),#P122 nvarchar(4000),#P121 nvarchar(4000),#P120 nvarchar(4000),#P119 nvarchar(4000),#P118 nvarchar(4000),#P117 nvarchar(4000),#P116 nvarchar(4000),#P115 nvarchar(4000),#P114 nvarchar(4000),#P113 nvarchar(4000),#P112 nvarchar(4000),#P111 nvarchar(4000),#P110 nvarchar(4000),#P109 nvarchar(4000),#P108 nvarchar(4000),#P107 nvarchar(4000),#P106 nvarchar(4000),#P105 nvarchar(4000),#P104 nvarchar(4000),#P103 nvarchar(4000),#P102 nvarchar(4000),#P101 nvarchar(4000),#P100 nvarchar(4000),#P99 nvarchar(4000),#P98 nvarchar(4000),#P97 nvarchar(4000),#P96 nvarchar(4000),#P95 nvarchar(4000),#P94 nvarchar(4000),#P93 nvarchar(4000),#P92 nvarchar(4000),#P91 nvarchar(4000),#P90 nvarchar(4000),#P89 nvarchar(4000),#P88 nvarchar(4000),#P87 nvarchar(4000),#P86 nvarchar(4000),#P85 nvarchar(4000),#P84 nvarchar(4000),#P83 nvarchar(4000),#P82 nvarchar(4000),#P81 nvarchar(4000),#P80 nvarchar(4000),#P79 nvarchar(4000),#P78 nvarchar(4000),#P77 nvarchar(4000),#P76 nvarchar(4000),#P75 nvarchar(4000),#P74 nvarchar(4000),#P73 nvarchar(4000),#P72 nvarchar(4000),#P71 nvarchar(4000),#P70 nvarchar(4000),#P69 nvarchar(4000),#P68 nvarchar(4000),#P67 nvarchar(4000),#P66 nvarchar(4000),#P65 nvarchar(4000),#P64 nvarchar(4000),#P63 nvarchar(4000),#P62 nvarchar(4000),#P61 nvarchar(4000),#P60 nvarchar(4000),#P59 nvarchar(4000),#P58 nvarchar(4000),#P57 nvarchar(4000),#P56 nvarchar(4000),#P55 nvarchar(4000),#P54 nvarchar(4000),#P53 nvarchar(4000),#P52 nvarchar(4000),#P51 nvarchar(4000),#P50 nvarchar(4000),#P49 nvarchar(4000),#P48 nvarchar(4000),#P47 nvarchar(4000),#P46 nvarchar(4000),#P45 nvarchar(4000),#P44 nvarchar(4000),#P43 nvarchar(4000),#P42 nvarchar(4000),#P41 nvarchar(4000),#P40 nvarchar(4000),#P39 nvarchar(4000),#P38 nvarchar(4000),#P37 nvarchar(4000),#P36 nvarchar(4000),#P35 nvarchar(4000),#P34 nvarchar(4000),#P33 nvarchar(4000),#P32 nvarchar(4000),#P31 nvarchar(4000),#P30 nvarchar(4000),#P29 nvarchar(4000),#P28 nvarchar(4000),#P27 nvarchar(4000),#P26 nvarchar(4000),#P25 nvarchar(4000),#P24 nvarchar(4000),#P23 nvarchar(4000),#P22 nvarchar(4000),#P21 nvarchar(4000),#P20 nvarchar(4000),#P19 nvarchar(4000),#P18 nvarchar(4000),#P17 nvarchar(4000),#P16 nvarchar(4000),#P15 nvarchar(4000),#P14 nvarchar(4000),#P13 nvarchar(4000),#P12 nvarchar(4000),#P11 nvarchar(4000),#P10 nvarchar(4000),#P9 nvarchar(4000),#P8 nvarchar(4000),#P7 nvarchar(4000),#P6 nvarchar(4000),#P5 nvarchar(4000),#P4 nvarchar(4000),#P3 nvarchar(4000),#P2 nvarchar(4000),#P1 nvarchar(4000),#P0 nvarchar(4000))select p.id as productId, p.external_id as externalId from products p where p.id in (#P0, #P1, #P2, #P3, #P4, #P5, #P6, #P7, #P8, #P9, #P10, #P11, #P12, #P13, #P14, #P15, #P16, #P17, #P18, #P19, #P20, #P21, #P22, #P23, #P24, #P25, #P26, #P27, #P28, #P29, #P30, #P31, #P32, #P33, #P34, #P35, #P36, #P37, #P38, #P39, #P40, #P41, #P42, #P43, #P44, #P45, #P46, #P47, #P48, #P49, #P50, #P51, #P52, #P53, #P54, #P55, #P56, #P57, #P58, #P59, #P60, #P61, #P62, #P63, #P64, #P65, #P66, #P67, #P68, #P69, #P70, #P71, #P72, #P73, #P74, #P75, #P76, #P77, #P78, #P79, #P80, #P81, #P82, #P83, #P84, #P85, #P86, #P87, #P88, #P89, #P90, #P91, #P92, #P93, #P94, #P95, #P96, #P97, #P98, #P99, #P100, #P101, #P102, #P103, #P104, #P105, #P106, #P107, #P108, #P109, #P110, #P111, #P112, #P113, #P114, #P115, #P116, #P117, #P118, #P119, #P120, #P121, #P122, #P123, #P124, #P125, #P126, #P127, #P128, #P129, #P130, #P131, #P132, #P133, #P134, #P135, #P136, #P137, #P138, #P139, #P140, #P141, #P142, #P143, #P144, #P145, #P146, #P147, #P148, #P149, #P150, #P151, #P152, #P153, #P154, #P155, #P156, #P157, #P158, #P159, #P160, #P161, #P162, #P163, #P164, #P165, #P166, #P167, #P168, #P169, #P170, #P171, #P172, #P173, #P174, #P175, #P176, #P177, #P178, #P179, #P180, #P181, #P182, #P183, #P184, #P185, #P186, #P187, #P188, #P189, #P190, #P191, #P192, #P193, #P194, #P195, #P196, #P197, #P198, #P199, #P200, #P201, #P202, #P203, #P204, #P205, #P206, #P207, #P208, #P209, #P210, #P211, #P212, #P213, #P214, #P215, #P216, #P217, #P218, #P219, #P220, #P221, #P222, #P223, #P224, #P225, #P226, #P227, #P228, #P229, #P230, #P231, #P232, #P233, #P234, #P235, #P236, #P237, #P238, #P239, #P240, #P241, #P242, #P243, #P244, #P245, #P246, #P247, #P248, #P249, #P250, #P251, #P252, #P253, #P254, #P255, #P256, #P257, #P258, #P259, #P260, #P261, #P262, #P263, #P264, #P265, #P266, #P267, #P268, #P269, #P270, #P271, #P272, #P273, #P274, #P275, #P276, #P277, #P278, #P279, #P280, #P281, #P282, #P283, #P284, #P285, #P286, #P287, #P288, #P289, #P290, #P291, #P292, #P293, #P294, #P295, #P296, #P297, #P298, #P299, #P300, #P301, #P302, #P303, #P304, #P305, #P306, #P307, #P308, #P309, #P310, #P311, #P312, #P313, #P314, #P315, #P316, #P317, #P318, #P319, #P320, #P321, #P322, #P323, #P324, #P325, #P326, #P327, #P328, #P329, #P330, #P331, #P332, #P333, #P334, #P335, #P336, #P337, #P338, #P339, #P340, #P341, #P342, #P343, #P344, #P345, #P346, #P347, #P348, #P349, #P350, #P351, #P352, #P353, #P354, #P355, #P356, #P357, #P358, #P359, #P360, #P361, #P362, #P363, #P364, #P365, #P366, #P367, #P368, #P369, #P370, #P371, #P372, #P373, #P374, #P375, #P376, #P377, #P378, #P379, #P380, #P381, #P382, #P383, #P384, #P385, #P386, #P387, #P388, #P389, #P390, #P391, #P392, #P393, #P394, #P395, #P396, #P397, #P398, #P399, #P400, #P401, #P402, #P403, #P404, #P405, #P406, #P407, #P408, #P409, #P410, #P411, #P412, #P413, #P414, #P415, #P416, #P417, #P418, #P419, #P420, #P421, #P422, #P423, #P424, #P425, #P426, #P427, #P428, #P429, #P430, #P431, #P432, #P433, #P434, #P435, #P436, #P437, #P438, #P439, #P440, #P441, #P442, #P443, #P444, #P445, #P446, #P447, #P448, #P449, #P450, #P451, #P452, #P453, #P454, #P455, #P456, #P457, #P458, #P459, #P460, #P461, #P462, #P463, #P464, #P465, #P466, #P467, #P468, #P469, #P470, #P471, #P472, #P473, #P474, #P475, #P476, #P477, #P478, #P479, #P480, #P481, #P482, #P483, #P484, #P485, #P486, #P487, #P488, #P489, #P490, #P491, #P492, #P493, #P494, #P495, #P496, #P497, #P498, #P499, #P500, #P501, #P502, #P503, #P504, #P505, #P506, #P507, #P508, #P509, #P510, #P511, #P512, #P513, #P514, #P515, #P516, #P517, #P518, #P519, #P520, #P521, #P522, #P523, #P524, #P525, #P526, #P527, #P528, #P529, #P530, #P531, #P532, #P533, #P534, #P535, #P536, #P537, #P538, #P539, #P540, #P541, #P542, #P543, #P544, #P545, #P546, #P547, #P548, #P549, #P550, #P551, #P552, #P553, #P554, #P555, #P556, #P557, #P558, #P559, #P560, #P561, #P562, #P563, #P564, #P565, #P566, #P567, #P568, #P569, #P570, #P571, #P572, #P573, #P574, #P575, #P576, #P577, #P578, #P579, #P580, #P581, #P582, #P583, #P584, #P585, #P586, #P587, #P588, #P589, #P590, #P591, #P592, #P593, #P594, #P595, #P596, #P597, #P598, #P599, #P600, #P601, #P602, #P603, #P604, #P605, #P606, #P607, #P608, #P609, #P610, #P611, #P612, #P613, #P614, #P615, #P616, #P617, #P618, #P619, #P620, #P621, #P622, #P623, #P624, #P625, #P626, #P627, #P628, #P629, #P630, #P631, #P632, #P633, #P634, #P635, #P636, #P637, #P638, #P639, #P640, #P641, #P642, #P643, #P644, #P645, #P646, #P647, #P648, #P649, #P650, #P651, #P652, #P653, #P654, #P655, #P656, #P657, #P658, #P659, #P660, #P661, #P662, #P663, #P664, #P665, #P666, #P667, #P668, #P669, #P670, #P671, #P672, #P673, #P674, #P675, #P676, #P677, #P678, #P679, #P680, #P681, #P682, #P683, #P684, #P685, #P686, #P687, #P688, #P689, #P690, #P691, #P692, #P693, #P694, #P695, #P696, #P697, #P698, #P699, #P700, #P701, #P702, #P703, #P704, #P705, #P706, #P707, #P708, #P709, #P710, #P711, #P712, #P713, #P714, #P715, #P716, #P717, #P718, #P719, #P720, #P721, #P722, #P723, #P724, #P725, #P726, #P727, #P728, #P729, #P730, #P731, #P732, #P733, #P734, #P735, #P736, #P737, #P738, #P739, #P740, #P741, #P742, #P743, #P744, #P745, #P746, #P747, #P748, #P749) I was trying to contact Azure's support and they recommended to add a FORCESEEK hint to the query - Do you know how to add this query hint to the springdata repository? Thank you.
The problem in this case is that the parameters are handles as Unicode (nvarchar) and my indexes where Ascii [char(36)]. Due to that reason it seems the searches are not executed using the indexes which make is very small. It seems like a normal behavior since Java strings are Unicode and there is no real way for the DB to down convert Unicode to Ascii. After modifying my id columns (PK and FK) from char(36) to nchar(36) the parameterized queries run as expected and running a search with IN clause of 2,000 ids takes about 400msec instead of almost 10 minutes.
Changing datasource not working
I have a an Access form with a subform in datasheet mode with edit mode allowed. All tables are stored inside an SQL Server (2008R2) and I just added a new column (bit not null default 0) The subform datasource span on 3 tables and is working just fine as it is. However, as soon as I add a new column, everytime I try to change data, I get this error : If I remove the column I just added, everything seems to work again. Here is the datasource before SELECT tblCommandeListe.Section, tblCommandeListe.Description, tblCommandeListe.[No item], tblCommandeListe.N°Commande, tblCommandeListe.Code, tblCommandeListe.Qte, tblCommandeListe.Dim, tblFournisseur.[Fournisseur-Nom], tblCommandeListe.Prix, tblCommandeListe.[Date de livraison], tblCommandeListe.[Cost Center], tblCommandeListe.Devise, tblCommandeListe.Complet, tblCommandeListe.[LB/Lin], tblCommandeListe.[Prix/lb], tblCommandeListe.Unite, tblCommandeListe.[Note 2], tblCo mmandeListe.Ordre, tblProduits.[Produit-DescriptionFRA], tblProduits.[Produit-Prix], tblProduits.[Produit-Unite], tblProduits.[Produit-Fournisseur], tblProduits.[Produit-LB/Lin], tblProduits.[Produit-Prix/lb], tblProduits.[Produit-Long nom], tblProduits.[Produit-Devise], tblCommandeListe.Condition, tblCommandeListe.[Date création], tblCommandeListe.[Enlever liste à commander], tblCommandeListe.[Unite ing], tblProduits.[Produit-Unite_ing], tblCommandeListe.[Dim ing], tblCommandeListe.DescTmp, tblCommandeListe.[User mod], tblCommandeListe.[Qte req], tblCommandeListe.Annuler, IIf(IsNull([Qte req]),0,[Qte req])*IIf(IsNull([Prix]),0,[Prix])*IIf(IsNull([Dim]),1,[Dim])*IIf(IsNull([LB/Lin]) Or [LB/Lin]=0,1,[LB/Lin]) AS Total, tblCommandeListe.[Relaché pour achat], tblProduits.[Produit-Priorité], tblFournisseur.[Fournisseur-Nom] FROM (tblCommandeListe LEFT JOIN tblProduits ON tblCommandeListe.Code = tblProduits.[Produit- Code]) LEFT JOIN tblFournisseur ON tblProduits.[Produit-Fournisseur] = tblFournisseur.Fournisseur_id ORDER BY tblCommandeListe.Section, tblCommandeListe.Description; and after I add the column SELECT tblCommandeListe.Section, tblCommandeListe.Description, tblCommandeListe.[No item], tblCommandeListe.N°Commande, tblCommandeListe.Code, tblCommandeListe.Qte, tblCommandeListe.Dim, tblFournisseur.[Fournisseur-Nom], tblCommandeListe.Prix, tblCommandeListe.[Date de livraison], tblCommandeListe.[Cost Center], tblCommandeListe.Devise, tblCommandeListe.Complet, tblCommandeListe.[LB/Lin], tblCommandeListe.[Prix/lb], tblCommandeListe.Unite, tblCommandeListe.[Note 2], tblCommandeListe.Ordre, tblProduits.[Produit-DescriptionFRA], tblProduits.[Produit-Prix], tblProduits.[Produit-Unite], tblProduits.[Produit-Fournisseur], tblProduits.[Produit-LB/Lin], tblProduits.[Produit-Prix/lb], tblProduits.[Produit-Long nom], tblProduits.[Produit-Devise], tblCommandeListe.Condition, tblCommandeListe.[Date création], tblCommandeListe.[Enlever liste à commander], tblCommandeListe.[Unite ing], tblProduits.[Produit-Unite_ing], tblCommandeListe.[Dim ing], tblCommandeListe.DescTmp, tblCommandeListe.[User mod], tblCommandeListe.[Qte req], tblCommandeListe.Annuler, IIf(IsNull([Qte req]),0,[Qte req])*IIf(IsNull([Prix]),0,[Prix])*IIf(IsNull([Dim]),1,[Dim])*IIf(IsNull([LB/Lin]) Or [LB/Lin]=0,1,[LB/Lin]) AS Total, tblCommandeListe.[Relaché pour achat], tblProduits.[Produit-Priorité], tblFournisseur.[Fournisseur-Nom], tblCommandeListe.EstProduction FROM (tblCommandeListe LEFT JOIN tblProduits ON tblCommandeListe.Code = tblProduits.[Produit- Code]) LEFT JOIN tblFournisseur ON tblProduits.[Produit-Fournisseur] = tblFournisseur.Fournisseur_id ORDER BY tblCommandeListe.Section, tblCommandeListe.Description; The only difference I see is the new column at the end. I tried with other columns and so far, it still works after, so the problem might be the column itself, but how can that be ? EDIT : I just did a test and it seems I get the exact same message when I tried to edit it directly in the table in Access!
Why does ST_Union throw a "TopologyException: side location conflict"?
I'd like to understand the meaning of this error: Error: ERROR: GEOSUnaryUnion: TopologyException: side location conflict at 509222.06405540626 166742.77073020922 SQLState: XX000 ErrorCode: 0 Given from the following query: select ST_union(z.geom) from zaz z Postgis version: POSTGIS="2.1.0 r11822" GEOS="3.3.6-CAPI-1.7.6" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.9.2, released 2012/10/08" LIBXML="2.9.0" RASTER The problem can be reproduced with this query: select ST_AsText(ST_Union(z.geom)) from ( select ST_MPolyFromText('MULTIPOLYGON(((513571.981531803 166341.349774259,513116.037800698 166090.997380913,513119.013934713 166083.021341753,513122.34720481 166072.188213938,513124.013839858 166065.997855187,513126.037610988 166046.950597491,513126.037610988 166023.974842894,513117.942526467 165913.024566813,513116.990163582 165897.905806017,513104.966582162 165803.502835059,513104.60944608 165716.718767181,513124.013839858 164966.018723224,513054.967530709 164991.018248951,513040.682087437 164995.065791211,512771.639572476 165072.207184881,512658.070298462 165089.230671447,512620.332919151 165094.825803396,512222.007142577 165144.705809488,512088.319202621 165158.396025957,511825.467046411 165185.300277453,511437.260125488 165216.25207121,511039.767666438 165238.394508282,510637.275302243 165245.299139197,510278.115449307 165247.084819606,509844.671291355 165243.275368066,509480.630578634 165236.01360107,509195.516939992 165227.918516549,508870.642150909 167051.217259529,509104.804375213 166841.340288788,509222.064055406 166742.770730209,509415.631811745 166631.106181965,509727.887792604 166450.871506013,509849.6711965 166401.824817445,509922.407911828 166380.753788619,509986.811451913 166352.659083516,510105.975857876 166299.445807327,510225.259309199 166266.232151719,510464.302393288 166229.209044572,510544.777057055 166213.495056973,510668.227095999 166170.876817877,510762.034840154 166140.282160202,510828.938332812 166126.949079815,510890.365738883 166118.139723131,510959.05491195 166107.782776758,511018.33950153 166100.16387368,511066.076691131 166092.42592524,511097.742757051 166089.211700504,511281.786884542 166098.021057189,511590.471504583 166137.90125299,511730.825984733 166143.853521021,511766.896728995 166143.972566381,511806.419788715 166145.520156069,511905.108392654 166136.353663303,512001.535134742 166108.735139643,512202.95988488 166038.379331527,512434.145975169 165984.332737814,512507.120781218 165968.618750214,512581.643176955 165965.642616199,512654.379892283 166077.307164444,512784.496471421 166043.855418115,512787.948786879 166078.973799492,512787.948786879 166078.973799492,512767.830120937 166133.377529288,512774.020479688 166276.23196201,512799.020005415 166301.350533097,512836.400248644 166276.946234174,512874.018582594 166305.040939276,512838.066883692 166334.564188705,512845.090559968 166427.895751417,512806.996044575 166460.990361664,512846.757195016 166499.561058499,512858.899821797 166718.723567368,512820.329124962 166737.770825064,512833.900296071 166747.532544633,512821.043397126 166755.984765236,512877.708988772 166768.365482739,512893.899157814 166775.627249735,512930.68417424 166780.270018799,512977.469000957 166786.103241468,513181.393703668 166834.554703233,513269.011089071 166852.054371242,513314.605462182 166864.077952663,513568.886352428 166930.624309239,513908.760856946 167004.313387452,513964.593131069 167015.265560627,514336.967019032 167086.454686267,514356.252367449 167090.264137806,514374.10917154 167095.621179034,514433.274715759 166842.649787754,514423.036814747 166834.554703233,514403.037194166 166819.197851716,514302.443864457 166749.675361124,513950.664823878 166560.750373849,513571.981531803 166341.349774259)))') as geom union select ST_MPolyFromText('MULTIPOLYGON(((509658.841483455 166823.126348616,509700.031178223 166767.055983772,509737.292376092 166816.816944504,509780.982023433 166778.008156947,509821.338400677 166825.269165106,509862.051914003 166803.960045559,509727.887792604 166450.871506013,509415.631811745 166631.106181965,509480.987714716 166813.959855849,509442.417017881 166923.362542242,509390.751331379 167281.570032294,509425.988758117 167342.997438364,509448.012149829 167345.97357238,509478.963943585 167352.04488577,509503.963469312 167355.021019785,509530.986766168 167357.9971538,509555.986291895 167357.9971538,509583.961951636 167358.949516685,509588.009493897 167357.9971538,509603.009209333 167068.955018259,509651.579716458 167025.622507,509658.841483455 166823.126348616)),((509222.064055406 166742.770730209,509288.967548065 167023.955871951,509248.373080099 167078.002465664,509288.967548065 167023.955871951,509222.064055406 166742.770730209)))') as geom ) z I'd also like to know if there is a way to "fix" one of the geometries to avoid the error. Strangely, if I create a table with a union of the two above selects, and then run an ST_Union, then it doesn't fail.
ST_MakeValid solves the problem. The result can be passed to ST_Union: ST_Union(st_makeValid(t.geom)) For the explanation, it could not be better than this one: PostGIS: Tips for power users.
SOLR - How to handle inner Query
How would we query this clause in the SOLR and (Jobseeker.eid not in (select eid from jobseeker_emailresume where cid = #usecid# and datesent >= #createodbcdate(emaileddate)# )) To do it in SOLR i am creating list of inner query result and then i am doing like this -eid: (5210 OR 5357) It works PERFECT with small data but for large data it generates Error. Like -eid: (5210 OR 5357 OR 5405 OR 5408 OR 5492 OR 5575 OR 5700 OR 5817 OR 7179 OR 9054 OR 9358 OR 9947 OR 9948 OR 9953 OR 9999 OR 10086 OR 10290 OR 10430 OR 10492 OR 10835 OR 11022 OR 11144 OR 11250 OR 11289 OR 11417 OR 11459 OR 11571 OR 11885 OR 12033 OR 12322 OR 13130 OR 13511 OR 13712 OR 14237 OR 15103 OR 17193 OR 17929 OR 17930 OR 19110 OR 19111 OR 19979 OR 20165 OR 20182 OR 20653 OR 20754 OR 20813 OR 21878 OR 22049 OR 22057 OR 22262 OR 22298 OR 22506 OR 23372 OR 24114 OR 24617 OR 24897 OR 24986 OR 25252 OR 25842 OR 25924 OR 26202 OR 26225 OR 26230 OR 26937 OR 27239 OR 27511 OR 27903 OR 27904 OR 28113 OR 28153 OR 28280 OR 28342 OR 28459 OR 28611 OR 28635 OR 28726 OR 28806 OR 28842 OR 28852 OR 28921 OR 29033 OR 29034 OR 29313 OR 29415 OR 29502 OR 29742 OR 30633 OR 31149 OR 31406 OR 31545 OR 31653 OR 31822 OR 32585 OR 32678 OR 32784 OR 33239 OR 33291 OR 33778 OR 33875 OR 33966 OR 34153 OR 34249 OR 34549 OR 34559 OR 34598 OR 34873 OR 35084 OR 35183 OR 35230 OR 35268 OR 37163 OR 37226 OR 37920 OR 38503 OR 39127 OR 39311 OR 39428 OR 39838 OR 39976 OR 39977 OR 40094 OR 40226 OR 40804 OR 41591 OR 41592 OR 41593 OR 42967 OR 42968 OR 42969 OR 42970 OR 43984 OR 44102 OR 44391 OR 44441 OR 44442 OR 44443 OR 44906 OR 46454 OR 47307 OR 47308 OR 50076 OR 50800 OR 52786 OR 52865 OR 54051 OR 54713 OR 54795 OR 55244 OR 55347 OR 57156 OR 57519 OR 57530 OR 57935 OR 58160 OR 58715 OR 59089 OR 62793 OR 65067 OR 66103 OR 66755 OR 66879 OR 66895 OR 67307 OR 67557 OR 67558 OR 67559 OR 67929 OR 68328 OR 69549 OR 69949 OR 69950 OR 70374 OR 70397 OR 71441 OR 71442 OR 72188 OR 72227 OR 72850 OR 73268 OR 73572 OR 73573 OR 73574 OR 75603 OR 76204 OR 77218 OR 77965 OR 78594 OR 81761 OR 81785 OR 81958 OR 82557 OR 83013 OR 83610 OR 83748 OR 83805 OR 84204 OR 84392 OR 85277 OR 85611 OR 85687 OR 85771 OR 85940 OR 86147 OR 86419 OR 86503 OR 86526 OR 86773 OR 86807 OR 86825 OR 87212 OR 87524 OR 87586 OR 87599 OR 87601 OR 87836 OR 87843 OR 87891 OR 88043 OR 88065 OR 88080 OR 88171 OR 88282 OR 88345 OR 88541 OR 88565 OR 88571 OR 88610 OR 88932 OR 88980 OR 88998 OR 89253 OR 89334 OR 89534 OR 89775 OR 89903 OR 90201 OR 90721 OR 90780 OR 90786 OR 90973 OR 91167 OR 91235 OR 91356 OR 91436 OR 91469 OR 92098 OR 92319 OR 92358 OR 92379 OR 92407 OR 92933 OR 92974 OR 93844 OR 93857 OR 93859 OR 94165 OR 94332 OR 94400 OR 94543 OR 94590 OR 94608 OR 94764 OR 95006 OR 95185 OR 95186 OR 95200 OR 95372 OR 95516 OR 95535 OR 95691 OR 95844 OR 95858 OR 95890 OR 96032 OR 96127 OR 96333 OR 96402 OR 96411 OR 96516 OR 96642 OR 96717 OR 96746 OR 98073 OR 98192 OR 100637 OR 100778 OR 100801 OR 101278 OR 102111 OR 102901 OR 105136 OR 105324 OR 105361 OR 105423 OR 105953 OR 106042 OR 106307 OR 107282 OR 107554 OR 107682 OR 107909 OR 109035 OR 109866 OR 110052 OR 110239 OR 110482 OR 110582 OR 110614 OR 110905 OR 110910 OR 110918 OR 110940 OR 110982 OR 111103 OR 111214 OR 111555 OR 111559 OR 111588 OR 111671 OR 111694 OR 111994 OR 112156 OR 112201 OR 112289 OR 112533 OR 112543 OR 112723 OR 112764 OR 112767 OR 112931 OR 113229 OR 113380 OR 113912 OR 114591 OR 116450 OR 116479 OR 116602 OR 116914 OR 117119 OR 117439 OR 117591 OR 118100 OR 118277 OR 119008 OR 119150 OR 119936 OR 119988 OR 120225 OR 120394 OR 121408 OR 121604 OR 121652 OR 122078 OR 122229 OR 122338 OR 122460 OR 122548 OR 122691 OR 122887 OR 122954 OR 123121 OR 123334 OR 123617 OR 123773 OR 124005 OR 124116 OR 124488 OR 125024 OR 125768 OR 126244 OR 126255 OR 126408 OR 127314 OR 127333 OR 127524 OR 127835 OR 129178 OR 129751 OR 129866 OR 130052 OR 131160 OR 131324 OR 132218 OR 132774 OR 132821 OR 133195 OR 134343 OR 134467 OR 134881 OR 134944 OR 135164 OR 135237 OR 135401 OR 135798 OR 135841 OR 136082 OR 136302 OR 136448 OR 136534 OR 137779 OR 137975 OR 139485 OR 139756 OR 140653 OR 140863 OR 141163 OR 141299 OR 141688 OR 141990 OR 142498 OR 142906 OR 142949 OR 143705 OR 143746 OR 143824 OR 143871 OR 145840 OR 146122 OR 146942 OR 147171 OR 147294 OR 147561 OR 148267 OR 148440 OR 148745 OR 148828 OR 148893 OR 149351 OR 149689 OR 150281 OR 150460 OR 151143 OR 151317 OR 151400 OR 152527 OR 153523 OR 153674 OR 153682 OR 154264 OR 154726 OR 155019 OR 155271 OR 156261 OR 156734 OR 157062 OR 157532 OR 157787 OR 157989 OR 159032 OR 160365 OR 160686 OR 161064 OR 161199 OR 162974 OR 162976 OR 163037 OR 163041 OR 163083 OR 164013 OR 164308 OR 165056 OR 166001 OR 167875 OR 168324 OR 168465 OR 168476 OR 168481 OR 168805 OR 168971 OR 169667 OR 169781 OR 169791 OR 169799 OR 169823 OR 169839 OR 169856 OR 169861 OR 169906 OR 170054 OR 171688 OR 171918 OR 173448 OR 173693 OR 174269 OR 174759 OR 174912 OR 175261 OR 175456 OR 176489 OR 176530 OR 176817 OR 177421 OR 177718 OR 178016 OR 178568 OR 178658 OR 178784 OR 179218 OR 179502 OR 180755 OR 181379 OR 181444 OR 182098 OR 182188 OR 182239 OR 182353 OR 182844 OR 182881 OR 183303 OR 183916 OR 183988 OR 184592 OR 184650 OR 184748 OR 184929 OR 185504 OR 187055 OR 187957 OR 188624 OR 188742 OR 190526 OR 190629 OR 191002 OR 191788 OR 192750 OR 192986 OR 195237 OR 196425 OR 196724 OR 196854 OR 197644 OR 198748 OR 198779 OR 198854 OR 199987 OR 200263 OR 201314 OR 201554 OR 202916 OR 203482 OR 203692 OR 204459 OR 206788 OR 206899 OR 207005 OR 208235 OR 208911 OR 209473 OR 209556 OR 210399 OR 211285 OR 212181 OR 213541 OR 213964 OR 214121 OR 216028 OR 216099 OR 216350 OR 216671 OR 216993 OR 217188 OR 217370 OR 217908 OR 218010 OR 219557 OR 219577 OR 220999 OR 221478 OR 222383 OR 222859 OR 224069 OR 224193 OR 227344 OR 227755 OR 229869 OR 230524 OR 232757 OR 280657 OR 280778 OR 281397 OR 281457 OR 281579 OR 281696 OR 281869 OR 282037 OR 282428 OR 282833 OR 282847 OR 282863 OR 283643 OR 283900 OR 286425 OR 286669 OR 290646 OR 290652 OR 291032 OR 291627 OR 291690 OR 291937 OR 291988 OR 292571 OR 292954 OR 293107 OR 293140 OR 293770 OR 300440 OR 300676 OR 364729 OR 396076 OR 399672 OR 401771 OR 404663 OR 407833 OR 408291 OR 408417 OR 409144 OR 409869 OR 409932 OR 409972 OR 413848 OR 417121 OR 417175 OR 417271 OR 417731 OR 420873 OR 421311 OR 423860 OR 427704 OR 429494 OR 431623 OR 434445 OR 434770 OR 435192 OR 435272 OR 435691 OR 435789 OR 435806 OR 439094 OR 440242 OR 440775 OR 442692 OR 444563 OR 446094 OR 446317 OR 446329 OR 446613 OR 448782 OR 449934 OR 450137 OR 450291 OR 451289 OR 451378 OR 451449 OR 451533 OR 451539 OR 453204 OR 454019 OR 454117 OR 454225 OR 454289 OR 454626 OR 454645 OR 455264 OR 455290 OR 456226 OR 458453 OR 460800 OR 469149 OR 471859 OR 472154 OR 472344 OR 472484 OR 478639 OR 478899 OR 479693 OR 481099 OR 482096 OR 482188 OR 482669 OR 482737 OR 483798 OR 483997 OR 484034 OR 484194 OR 484829 OR 485099 OR 486072 OR 486118 OR 486292 OR 486360 OR 491205 OR 491275 OR 491565 OR 491723 OR 491864 OR 492085 OR 492101 OR 492146 OR 492157 OR 492317 OR 492331 OR 493187 OR 493320 OR 493335 OR 493450 OR 493493 OR 494028 OR 494134 OR 494246 OR 494443 OR 494509 OR 495028 OR 496430 OR 496731 OR 496783 OR 497485 OR 497815 OR 498808 OR 500728 OR 500930 OR 501121 OR 501373 OR 501870 OR 502361 OR 502952 OR 503053 OR 503147 OR 503379 OR 503964 OR 504193 OR 504603 OR 505969 OR 506023 OR 507031 OR 507783 OR 507798 OR 508141 OR 508318 OR 509092 OR 509641 OR 510189 OR 510448 OR 510532 OR 510999 OR 511803 OR 511959 OR 512096 OR 512487 OR 513490 OR 514019 OR 514020 OR 514223 OR 514481 OR 514539 OR 515171 OR 515184 OR 515492 OR 515564 OR 515723 OR 515750 OR 516834 OR 517032 OR 517070 OR 517179 OR 517956 OR 517959 OR 518742 OR 519145 OR 519156 OR 519317 OR 519474 OR 519615 OR 519648 OR 521519 OR 521556 OR 524181 OR 524972 OR 525103 OR 525163)
You need to make sure that your inner query does not exceed the maximum number of allowed boolean clauses. This maximum number can be configured in the configuration script.
Without knowing your domain logic a bit better, you may want to try to denormalize the logic in that subquery into your Solr search query. You have a subquery that's testing values that could themselves be indexed into Solr, allowing you to still do the bulk of your querying from Solr, and saving you from having to pass in a huge list of 'approved' IDs. Solr by default has a limit of 1,024 OR clauses. If you bump into this limit, you're probably doing something that's not really a good fit for Solr.