Does the number of columns affect query performance?

前端 未结 6 678
春和景丽
春和景丽 2021-01-03 21:23

CASE 1: I have a table with 30 columns and I query using 4 columns in the where clause.

CASE 2: I have a table with 6 columns and I query using 4 columns in the whe

6条回答
  •  走了就别回头了
    2021-01-03 21:40

    Since you specified you are using the WHERE clause it will depend on how many rows are returned. If the value in your WHERE clause is UNIQUE or a PRIMARY KEY than the difference is almost non-existent. You can use EXPLAIN ANALYZE in front of your SELECT statement to view the planning time and execution time values and than you can compare your queries.

提交回复
热议问题