php - ROW wise SUM VS COLUMN wise SUM in MySQL -
i have tablea contains following structure i modified structure tableb below reduce number of rows , category fixed length assume have 21 lakh data in tablea after modified new structure tableb contains 70k rows only in case want sum values table, query1: select sum(val) total tablea; vs query2: select sum(cate1+cate2+cate3) total tableb; query1 executing faster while comparing query2. tableb contains less rows while comparing tablea as of expectation query2 faster query1 fastest one. help me understand why performance reduced in query2? mysql optimized speed relational operations. there not effort @ speeding other kinds of operations mysql can perform. cate1+cate2+cate3 legitimate operation, there's nothing particularly relational it. table1 simpler in terms of relational model of data table2, though table1 has more rows. it's worth noting in passing table1 conforms first normal form table2 not. 3 columns repeating group though it's...