I need to apply a java regex on sql query string to calculate the count of it. I have to get what is between the "first select" and "from" of the principal query.
This is my example :
Query :
select name,(select age from subtable), adress from table where name in (select name from subtable1)
Result :
select count(*) from table where name in (select name from subtable1)
I was using replaceFirst("^(.*?)from", "select count(*) from") but it is not working because there is an sql query in the attribute.
Please anyone can help ?
EXPLAIN <query>be sufficient? And since you've also added the hibernate tag: AFAIK Hibernate can collect a bunch of statistics that might help as well.