Friday, 9 September 2016

Dynamic code generation bad for apps?

While using HSQLDB, H2 and others let code be created dynamically without your JAVA developer needing to think hard about the database it does come with some overheads.

First, the query in now created by a program that doesn't understand the intended outcome and sometimes because of this will create repeated queries for the same set of information, this doesn't show up in small unit testing, however, can become a large performance bottleneck when dealing with many thousands of transactions.

Second, these programs do not use any performance best practices and can be hard to link the java query to the actual SQL statement that is executed on the Database layer.

Such things that are overlooked are:
  • Network traffic caused by long query statements.
  • Slow and N+1 query issue.

With this in mind does such development style help?  Well yes if you're writing a program that is small and has a very small database.
If on the other hand you're expecting it to grow to a larger size and will continue to do so over years to come, you might have just shot yourself in the foot, as debugging performance issues will become a nightmare, this is not to say that the caching functions are not useful, however do not rely on them to write good queries for you.

No comments: