SQL:为什么许多行的SELECT比许多列

时间:2017-11-20 16:36:42

标签: sql postgresql

为什么SQL SELECT * FROM T_ROW;SELECT * FROM T_COLUMN;快?

表格中的数据总量相同。

说明:

T_COLUMN:
Seq Scan on t_column  (cost=0.00..2.05 rows=5 width=1995) (actual time=0.014..0.018 rows=5 loops=1)
    Buffers: shared hit: 2
Planning time: 0.184 ms
Execution time: 0.093 ms


T_ROW:
Seq Scan on t_row  (cost=0.00..4.00 rows=100 width=165) (actual time=0.015..0.024 rows=100 loops=1)
    Buffers: shared hit: 3
Planning time: 0.047 ms
Execution time: 0.040 ms

TABLES:

T_COLUMN
|| c1 | c2 | c3 | ..... | c99 | c100 ||

5

T_ROW
|| c1 | c2 | c3 | c4 | c5 ||

100

0 个答案:

没有答案