我正在阅读 Django Book 并遇到了有趣的声明。
Notice that Django doesn’t use SELECT * when looking up data and instead lists
all fields explicitly. This is by design:
in certain circumstances SELECT * can be slower,
我从http://www.djangobook.com/en/1.0/chapter05/得到这个
所以我的问题是有人能解释一下为什么SELECT *
比明确地调用每一列要慢。如果你能给我一些例子就好了。或者如果你认为相反(没关系),你能解释一下为什么吗?
更新:
那是表:
BEGIN;
CREATE TABLE "books_publisher" (
"id" serial NOT NULL PRIMARY KEY,
"name" varchar(30) NOT NULL,
"address" varchar(50) NOT NULL,
"city" varchar(60) NOT NULL,
"state_province" varchar(30) NOT NULL,
"country" varchar(50) NOT NULL,
"website" varchar(200) NOT NULL
);
这就是 Django 的调用方式SELECT * FROM book_publisher
:
SELECT
id, name, address, city, state_province, country, website
FROM book_publisher;