Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Optimizing the HQL statement in SAV Role

anekkilady
New Contributor
New Contributor

Hi,

I have a requirement where we need to restrict users in Access request without active managers. To achieve this, I am updating the end-user SAV role whom to request with an HQL statement. Below is the HQL statement that I am using:

select a from Users a where a.statuskey =1 and a.manager in (select id from Users where statuskey =1)

anekkilady_1-1725270478337.pnganekkilady_2-1725270505469.png

 

I want to optimize the above HQL, I tried using inner join, but it errors out and is not accepted in Saviynt, can you let me know if I can optimize the above HQL? 

Please note: This is HQL and not SQL.

Regards,

Arpitha 

8 REPLIES 8

indra_hema_95
Regular Contributor III
Regular Contributor III

Hi @anekkilady Can you try this?

select a from Users a where a.statuskey = 1 and a.manager in (select id from Users u where u.statuskey = 1)

Regards,

Indra

anekkilady
New Contributor
New Contributor

Thank you for your response @indra_hema_95. This is the same query that I have pasted and needs to be optimized.

Regards,

Arpitha 

indra_hema_95
Regular Contributor III
Regular Contributor III

Hi @anekkilady There is a small difference in my query can you just copy and paste and see if it errors out or not?

Regards,

Indra

Amit_Malik
Valued Contributor II
Valued Contributor II

Hi @anekkilady , try this 

Amit_Malik_0-1725274729984.png

 

select a from Users a, Users aa where a.manager=aa.id and aa.statuskey=1 and a.statuskey=1

 

 

Kind Regards,
Amit Malik
If this helped you move forward, please click on the "Kudos" button.
If this answers your query, please select "Accept As Solution".

rushikeshvartak
All-Star
All-Star

select u
from Users u
join Users m on u.manager = m.id
where u.statuskey = 1
and m.statuskey = 1


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

anekkilady
New Contributor
New Contributor

Thank you for your response. 

@Amit_Malik The query given below is accepted however, I do not see any users when I try to place the access request for others.

select a from Users a, Users aa where a.manager=aa.id and aa.statuskey=1 and a.statuskey=1

anekkilady_0-1725444249526.png

 

 

@rushikeshvartak  As mentioned in the note, join is  not accepted, were you able to use this in your environment?

@indra_hema_95 I am using the query that you have provided and that is working fine. Thank you! Can we optimize this more?

Regards,

Arpitha N

 

Amit_Malik
Valued Contributor II
Valued Contributor II

Hi @anekkilady , 

Internally Saviynt is only picking condition after where, it is not joining tables

select a from Users a, Users aa where a.manager=aa.id and aa.statuskey=1 and a.statuskey=1 becomes

REQ=select a from Users a where ( ( a.manager=aa.id and aa.statuskey=1 and a.statuskey=1 ) )} "

This is why the join (via comma) is not giving any results

select a from Users a where a.statuskey =1 and a.manager in (select id from Users where statuskey =1) becomes

REQ=select a from Users a where ( ( a.statuskey =1 and a.manager in (select id from Users where statuskey =1) ) )} "

 

 

I am afraid we can not optimize it to the extent you want looking at how the queries transforms behind the scene

 

Kind Regards,
Amit Malik
If this helped you move forward, please click on the "Kudos" button.
If this answers your query, please select "Accept As Solution".

Below query worked for me

select a from Users a where a.statuskey =1 and a.manager in (select mmmm.id from Users mmmm where mmmm.statuskey =1)


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.