<div dir="ltr"><div><div><div><div>> 1. DAO files might become very long.<br><br>They would not be much longer than the current alternative, the .sql files.<br><br>> 2. An inflation of business entities to represent partial populated
business entity or inflation of mappers inflation (this will be required
for SP as well).<br></div><br>This isn't a problem of the DAO layer but bad design of business objects that do not verify their own state. That could happen in any layer and happens in existing DAO that uses stored procedures already.<br><br>> 3. An inflation of business entities to represent partial populated
business entity or inflation of mappers inflation (this will be required
for SP as well).<br></div><br>Look at my patches: one of them returns list of ids and another one returns whole Cluster object and uses the existing RowMapper that populates the whole Cluster object, so in both cases no much effort is needed in order to keep the current state in terms of BE completness. IMHO having to create a new class for a specific query would be the limit that will stop people from creating queries that return something that isn't an existing type. Anyhow I do not see how the proposed is changes the current state, can't we do the same with a stored procedure?<br><br>> 4.1 Beside of the fact that a multi-line concatenated string that cannot be
easily copied and run with psql, it means that we should compile the
code in order to test the change (vs building with DEV_REBUILD=0 which
only package the SQL file).<br><br>Running a unit-test in your IDE after updating the in-code SQL is even faster than the current flow.<br><br>> 4.2 No syntax highlighting when performing code review. i.e. I don't think reviewing a patch such as <a href="https://gerrit.ovirt.org/#/c/66729/10/packaging/dbscripts/network_sp.sql" target="_blank">https://gerrit.ovirt.org/#/c/<wbr>66729/10/packaging/dbscripts/<wbr>network_sp.sql</a> would be more clear inside a java file.<br><br></div><div>If you review the DAO Java code in your IDE (I'd recommend that for any Java change) you get the hiighlighting too. Beside that a code is written/reviewed only once but is read many times and here my proposal is much easier.<br></div><div><br>> 4.3 The user permissions management is implemented on DB level. That means
that SQL will be more complex (more concatenated java lines). <br><br>We can keep those long queries in SPs if you like. But I'm in favor to enable the shorter one to be in-lined.<br><br>> 5. Stored procedure are cached by project's code. See SimpleJdbcCallsHandler.getCall<wbr>(),
while the NamedParameterJdbcTemplate are cached by spring's code which
seems less optimal (sync all calls using synchronized vs using
ConcurrentHashMap as in SP cache).<br></div><br>I'm not sure that this caching code is needed. Has this proven impact/need? Are we pioneers in JDBC area? How other projects do that?<br><br>> 6. With the NamedParametersJdbcTemplate there is no use of the DbEngineDialect. What's the impact of it ?<br></div><br>In my patches I do use it through<span style="background-color:rgb(85,85,85)"><span style="background-color:rgb(255,255,255)"> getCustomMapSqlParameterSource.</span></span><div><div><div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 27, 2017 at 1:56 AM, Moti Asayag <span dir="ltr"><<a href="mailto:masayag@redhat.com" target="_blank">masayag@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Sun, Mar 26, 2017 at 5:12 PM, Yevgeny Zaspitsky <span dir="ltr"><<a href="mailto:yzaspits@redhat.com" target="_blank">yzaspits@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi All,<br><br></div>Recently I had a task of performance improvement in one of our network related flows and had some hard time following our DAL code and one of the outcomes of the task was defining a couple of new quite simple, but neat queries.<br>When I came to coding those new queries I remembered how hard was following the existing DAL code, I decided to make my own new methods clearer. So I created [1] and [2] patches. <br><br>Everything is quite standard there beside the fact that they do not use any stored procedure, but use SQL directly, IMHO by that they save time that I spent in trying to follow what a DAO method does. Looking into the method code you get the understanding of what this method is all about:<br><ul><li>no looking for a stored procedure name that is buried in the DAO class hierarchy<br></li><li>no looking for the SP definition</li></ul></div></div></div></div></blockquote><div><br></div></span><div>There are additional pros and cons for the suggestion to consider:<br><br></div><div>Pros:<br></div><div><ol><li>No need to run engine-setup after changing DB related code (in case of SQL inside Java). <br></li></ol></div><div>Cons:<br></div><ol><li>DAO files might become very long.</li><li>If you decide to return the business entity associated with the DAO as a returned object, you won't know as a caller which fields to expect to be populated, which lead to 3:</li><li>An inflation of business entities to represent partial populated business entity or inflation of mappers inflation (this will be required for SP as well).</li><li>SQL code inside of Java: <br></li><ol><li>Beside of the fact that a multi-line concatenated string that cannot be easily copied and run with psql, it means that we should compile the code in order to test the change (vs building with DEV_REBUILD=0 which only package the SQL file).</li><li>No syntax highlighting when performing code review. i.e. I don't think reviewing a patch such as <a href="https://gerrit.ovirt.org/#/c/66729/10/packaging/dbscripts/network_sp.sql" target="_blank">https://gerrit.ovirt.org/#/c/<wbr>66729/10/packaging/dbscripts/<wbr>network_sp.sql</a> would be more clear inside a java file.</li><li>The user permissions management is implemented on DB level. That means that SQL will be more complex (more concatenated java lines). </li></ol><li>Stored procedure are cached by project's code. See SimpleJdbcCallsHandler.getCall<wbr>(), while the NamedParameterJdbcTemplate are cached by spring's code which seems less optimal (sync all calls using synchronized vs using ConcurrentHashMap as in SP cache).</li><li>With the NamedParametersJdbcTemplate there is no use of the DbEngineDialect. What's the impact of it ? </li></ol><div>So besides 5 and 6, the rest is a matter of style. I'd like to hear more opinions from other members.<br><br></div><div>Regards,<br></div><div>Moti<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class=""><div><div><div><div>So I'd like to propose moving towards this approach in general in all cases when nothing beyond a simple SQL is needed (no stored procedure programming language is needed).<br>From my experience with the performance improvement task it looks like people avoid adding new queries for a specific need of a flow, instead they use the existing general ones (e.g. dao.getAllForX()) and do the actual join in the bll code.<br>IMHO the proposed approach would simplify adding new specific queries and by that would prevent a decent part of performance issues in the future.<br><br></div><div>I do not propose changing all existing SP's to inline queries in a once, but to allow adding new queries this way. Also we might consider converting relatively simple SP's to inline SQL statements later in a graduate way.<br></div><br>[1] - <a href="https://gerrit.ovirt.org/#/c/74456" target="_blank">https://gerrit.ovirt.org/#/c/7<wbr>4456</a><br>[2] - <a href="https://gerrit.ovirt.org/#/c/74458" target="_blank">https://gerrit.ovirt.org/#/c/7<wbr>4458</a><br><br></div>Regards,<br></div>Yevgeny<br></div>
<br></span>______________________________<wbr>_________________<br>
Devel mailing list<br>
<a href="mailto:Devel@ovirt.org" target="_blank">Devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman<wbr>/listinfo/devel</a><span class="HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div class="gmail_extra"><br clear="all"><br>-- <br><div class="m_2617079675823966324gmail-m_1038891330517396707gmail_signature"><div dir="ltr"><div>Regards,<br></div>Moti<br></div></div>
</div></font></span></div>
</blockquote></div><br></div>