Query too long to execute or server is too busy #6357
-
We recently migrated from 3.7 to 4.2.3. We had this large ecsql query that was previously supported.
After migrating, to 4,2 and updating "iModelConnection.query" to "iModelConnection.createQueryReader" we get 504 timeouts and "Query too long to execute or server is too busy" error. Tried setting the quota: { time: 10000 }, didn't help. Is there any configuration/properties we need to add to support such queries or can it be a regression? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
I can't say why it worked in 3.7.x and stopped working in 4.x - tagging @khanaffan for that. But here are a few changes that you can try making to the query to make it more performant:
|
Beta Was this translation helpful? Give feedback.
-
By looking at the query it has a lot of unnecessary joins and string processes. I read the query as follows
If the above is correct then you can reduce the query to following. It is still a bit slower you might want to exclude SELECT
c.Name AS className,
c.DisplayLabel AS classLabel,
p.Name AS Name,
p.DisplayLabel AS AttributeDisplayLabel
FROM ECDbMeta.ECClassDef c
JOIN ECDbMeta.ECPropertyDef p ON c.ECInstanceId = p.Class.Id
JOIN (
SELECT DISTINCT cac.TargetECInstanceId classId FROM ECDbMeta.ClassHasAllBaseClasses cac
WHERE cac.SourceECInstanceId IN (SELECT DISTINCT ECClassId FROM [BisCore].[ElementAspect])
) ea ON ea.classId = c.ECInstanceId A much faster version of query with the same result will be a query that excludes SELECT
c.Name AS className,
c.DisplayLabel AS classLabel,
p.Name AS Name,
p.DisplayLabel AS AttributeDisplayLabel
FROM ECDbMeta.ECClassDef c
JOIN ECDbMeta.ECPropertyDef p ON c.ECInstanceId = p.Class.Id
JOIN (
SELECT DISTINCT cac.TargetECInstanceId classId FROM ECDbMeta.ClassHasAllBaseClasses cac
WHERE cac.SourceECInstanceId IN (SELECT DISTINCT ECClassId FROM [BisCore].[ElementAspect] WHERE ECClassId <> ec_classId('BisCore:ExternalSourceAspect'))
UNION
SELECT ec_classId('BisCore:ExternalSourceAspect')
) ea ON ea.classId = c.ECInstanceId |
Beta Was this translation helpful? Give feedback.
-
@khanaffan's answer is great but I wanted to mention that |
Beta Was this translation helpful? Give feedback.
By looking at the query it has a lot of unnecessary joins and string processes. I read the query as follows
className
,classLabel
,propertyName
&propertyLabel
.If the above is correct then you can reduce the query to following. It is still a bit slower you might want to exclude
BisCore.ExternalSourceAspect