Inefficient SQL query

Context

Implementation,Network,Database

Affects

Efficiency

Problem

To retrieve data from a database a SQL query is sent over a JDBC connection to a remote server.

Refactorings

Use JSON query

Resolves

Efficiency

Affects

Solution

According to an answer in Programmers Stackexchange the use of a SQL query is discouraged as it introduces a lot of overhead. It should be preferred to send a query to webserver and revieve e.g. a * response. This response could be compressed efficiently.

Beyond that the projection of a query should be minimised:

/* BAD */
select * from verybigtable
/* BETTER */
select id, singlecolumn from verybigtable

Links

Related