We have a system in GX EV3 u2 generating Java and connecting to Postgresql 9.3. Overall the performance is acceptable, but at certain times we have bottlenecks and I noticed that they happen just when a query with LIKE is executed.
Looking further, I discovered that the problem is when GX generates code for instruction with LIKE, it fills the field size with characters% and then Postgres ends up generating a bad execution plan for the query. If you take (by hand) the excess of%, the query is fast.Eg: in an address search field; "varchar address (120)", the generated code for a search becomes something like
select endereco from cliente where endereco like 'rua do brasil%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
A query like this runs in 1.35 seconds, but removing the excess of%, leaving only 1, the same query runs in 0.33 sec.
How can I solve this problem? What can / should be done to get around or solve it for good? Is it a GX bug or is it being programmed that it should be improved?