X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id F149C30DECD for ; Wed, 11 Jun 2003 13:12:16 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 02203-03 for ; Wed, 11 Jun 2003 10:12:06 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 6701530DE72 for ; Wed, 11 Jun 2003 10:12:04 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h5BDBoU6010302; Wed, 11 Jun 2003 09:11:50 -0400 (EDT) To: Hilary Forbes Cc: pgsql-sql@postgresql.org Subject: Re: Record size In-reply-to: <5.1.0.14.0.20030611092555.02ff5e80@mailserver.ipl.co.uk> References: <5.1.0.14.0.20030611092555.02ff5e80@mailserver.ipl.co.uk> Comments: In-reply-to Hilary Forbes message dated "Wed, 11 Jun 2003 09:35:16 +0100" Date: Wed, 11 Jun 2003 09:11:50 -0400 Message-ID: <10301.1055337110@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200306/90 X-Sequence-Number: 13848 Hilary Forbes writes: > Now the question. Does the number of fields that you have in a record and indeed their size affect performance on a SELECT statement when only a subset of fields is being extracted? So suppose that I have > f1 integer > f2 varchar(4) > f3 varchar(20) > f4 text > and f4 contains reams of data. (well eg 4k). If I just want f1 and f2, will the performance of the SELECT statement be affected by the fact that f4 is large in physical size? If so, I would be better having two parallel tables one with fields f1,f2,f3 and one with f1,f4 as most of the time I don't want to read in the f4. Most of the possible benefit applies automatically, because large values of f4 will be "toasted" (moved out of line). I don't think it's worth contorting your table structure for. You might care to run some experiments to verify that theory, though. (But update first; experiments against 7.0 don't necessarily prove anything about 7.3 ...) > As a secondary question, presumably it is better to have a permanently compiled view in the database defined as > CREATE VIEW myview as SELECT f1,f2,f3 from mytable > rather than issuing the query each time direct to the underlying table? There's essentially no difference in performance. Views are not pre-optimized. regards, tom lane