Let's say that I have a table t
with 4 normal columns n1
, n2
, n3
, n4
and 1 virtual computed column, c1
. If I run the following query:
select n1, n2 from t;
, is the value of c1
computed for each row, even though I have not included it in the columns that I am selecting?
According to the offical MySQL documentation here https://dev.mysql.com/doc/refman/5.7/en/create-table-generated-columns.html :
VIRTUAL: Column values are not stored, but are evaluated when rows are read, immediately after any BEFORE triggers.
It says, rows are read
, not columns are read
. Hence, the confusion.
To ground this in reality, here is my actual situation: I am selecting (no where clause) from such a table as described above and it is being really slow (as compared to other similar tables). I am not selecting the computed column, but I am guessing that it is still being computed, causing the slowness.