Hi, Anshu! Please, see the attached patch. It introduces a macro top_level_cond_is_satisfied() that now marks all places where a comparison (in the TIME_FOR_COMPARE sense) is done. So, all you need to do is to convert this macro into an (inline) function and increment your counter from there. As for TIME_FOR_COMPARE_ROWID, it's simpler. There's handler::cmp_ref(), a virtual handler method. Create handler::ha_cmp_ref(), non-virtual inline public method (make cmp_ref() protected, as usual). And increment your counter from ha_cmp_ref(). By the way, before you start writing the code to solve our equations, please write an email, explaining how you're going to solve them, that is, what method you'll be using. There are lots of them. Some are faster, some are slower. Some work better with sparse matrices (and ours will be very much sparse). Regards, Sergei