Histograms were introduced with MySQL 8.0 and are a valuable way of speeding up queries. The MySQL optimizer assumes that data in a column has evenly distributed values. Even distribution of data probably does not reflect much of the data sitting right now in your database.
The optimizer wants to find the most efficient
way to return the data requested in a query. If it has poor
information on that data, then the optimizer will make a
'guesstimate' that will will result in a query plan that will not
perform well. But if the optimizer has good information, in
this case provided by a histogram, then it can produce a better
query plan.
In the following example a able is filled with data
that is not evenly distributed. In the histogram image
following, the data is represented in what looks like a
rollercoaster side view.
…