My point might have been discussed previously. I beg your pardon if my message bothers
you.
As everybody knows, Hibernate will create very terse and mystic table alias. I often feel
frustrated by them when trying to read the SQL Hibernate has produced. There must be many
thoughts behind its current design, I think. Could we achieve the goal to avoid
sacrificing SQL readability while having our job done? Needless to say, experienced
Hibernate user still needs to understand the auto-generated SQL for many reasons
(troubleshooting, optimization), and a human-friendly SQL might make for a far better
user experience.
In terms of implementation, we can simulate human's thinking process when designing a
table alias (TBH, sometimes even human is frustrated to think of a most satisfying alias).
Many heuristics could be applied (e.g., hufman encoding algorithm) and it would be a good
selling point for v6.
Any thoughts? Again, pardon me if the point has been discussed previously.
Show replies by date
Hi Nathan,
this sounds worthwhile to me at a high level, but I'm not sure about
us being able to implement a reasonable heuristic. In particular, the
mentioned "huffman encoding" doesn't sound like an improvement over
the current strategy? I suppose you're not referring to the
compression algorithm? Maybe I misunderstand, it would help to see a
concrete example.
Thanks
On Wed, 26 Aug 2020 at 14:09, Nathan Xu <nathan.qingyang.xu(a)gmail.com> wrote:
>
> My point might have been discussed previously. I beg your pardon if my message
bothers you.
>
> As everybody knows, Hibernate will create very terse and mystic table alias. I often
feel frustrated by them when trying to read the SQL Hibernate has produced. There must be
many thoughts behind its current design, I think. Could we achieve the goal to avoid
sacrificing SQL readability while having our job done? Needless to say, experienced
Hibernate user still needs to understand the auto-generated SQL for many reasons
(troubleshooting, optimization), and a human-friendly SQL might make for a far better
user experience.
>
> In terms of implementation, we can simulate human's thinking process when
designing a table alias (TBH, sometimes even human is frustrated to think of a most
satisfying alias). Many heuristics could be applied (e.g., hufman encoding algorithm) and
it would be a good selling point for v6.
>
> Any thoughts? Again, pardon me if the point has been discussed previously.
> _______________________________________________
> hibernate-dev mailing list -- hibernate-dev(a)lists.jboss.org
> To unsubscribe send an email to hibernate-dev-leave(a)lists.jboss.org
> %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
I simply gave an example that some existing tool or algorithm could be used. Obviously it
cannot be based on single heuristics and it is definitively a highly experimental
endeavour.
The applicability of huffman encoding is as following:
1. list all the involved tables with their frequency in the SQL;
2. use huffman algorithm to assign shorter alias to table with more frequency so the
overall SQL is the shortest
Again, just an example. Obviously SQL length cannot be the only perspective, if it
counts.
There are many more perspectives to take into consideration, e.g.:
* using common abbreviation convention (e.g., hibernate -> hbt);
* similar table names have similar abbreviations;
* ... ...
Just a high level thoughts. We can make incremental progress by simulating human pattern.
E.g., we can compare the SQL produced by Hibernate with the one provided by human and
inspect the difference. There should be tons of patterns and heuristics seems inevitable.
This should not be a normal issue solved by one single ticket. It involves research and
even the 'AI' buzzword.