HQL very slow

A HQL query I use is very slow.
SELECT
CONCAT(t.javaType,
'µ',
t.systemName) as v,
CASE
WHEN SIZE(t.SQLDatabaseColumns) > 0 THEN CONCAT(t.systemName,
' (',
SIZE(t.SQLDatabaseColumns),
')')
ELSE t.systemName
END as name
FROM
SQLDatabaseType t
WHERE
t.database.id = :db
ORDER BY
SIZE(t.SQLDatabaseColumns) DESC,
LENGTH(t.systemName) ASC,
SUBSTR(t.systemName,
1,
1) DESC
SELECT
CONCAT(t.javaType,
'µ',
t.systemName) as v,
CASE
WHEN SIZE(t.SQLDatabaseColumns) > 0 THEN CONCAT(t.systemName,
' (',
SIZE(t.SQLDatabaseColumns),
')')
ELSE t.systemName
END as name
FROM
SQLDatabaseType t
WHERE
t.database.id = :db
ORDER BY
SIZE(t.SQLDatabaseColumns) DESC,
LENGTH(t.systemName) ASC,
SUBSTR(t.systemName,
1,
1) DESC
What the query should do: The Query should output two columns: 1. Integerµint8 as a concat of the java-type, the letter 'µ' and then the database-native type. 2. int8 (29) what means that the type int8 is used 29 times. Ok, the reason why this query is slow is: SIZE(t.SQLDatabaseColumn) is executed multiple times. How to improve the speed in HQL?
2 Replies
JavaBot
JavaBot9mo ago
This post has been reserved for your question.
Hey @Peter Rader! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
JavaBot
JavaBot9mo ago
Post Closed
This post has been closed by <@574922348642172929>.
Want results from more Discord servers?
Add your server