Avoiding SELECT * and COUNT *

Avoiding SELECT * and COUNT * is a kind of logical reasoning; for example, imagine you have a use case where you are need an entire table. In these instances, you don't have any option in the matter, but there are drawbacks by doing this, such as the majority of the database resources would be used only for that query, resulting in degraded performance, and thus resulting in higher latencies, as this data would be huge, so it would take a longer time to acknowledge clients.

The syntax is as follows:

SELECT * FROM <tableName>;

The following screenshot shows an example of the result set of SELECT on all rows and columns:

Imagine you are querying an entire table that's 100 GB; an entire 100 GB of data needs be ...

Get Advanced MySQL 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.