X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E3A1C3A3ECD for ; Tue, 23 Nov 2004 14:59:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76475-06 for ; Tue, 23 Nov 2004 14:59:35 +0000 (GMT) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by svr1.postgresql.org (Postfix) with ESMTP id 1C02A3A3EEA for ; Tue, 23 Nov 2004 14:59:38 +0000 (GMT) Received: (qmail 1136 invoked from network); 23 Nov 2004 14:59:38 -0000 Received: from mail.kinesis-cem.com (HELO pdarley) ([64.81.9.230]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 23 Nov 2004 14:59:37 -0000 From: "Peter Darley" To: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= , Subject: Re: Data type to use for primary key Date: Tue, 23 Nov 2004 06:59:42 -0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/350 X-Sequence-Number: 9304 All, Well, you should still escape any strings you're getting from a web page so you can ensure you're not subject to a SQL insert attack, even if you're expecting integers. Thanks, Peter Darley -----Original Message----- From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Pierre-Frédéric Caillaud Sent: Monday, November 22, 2004 3:06 PM To: pgsql-performance@postgresql.org Subject: Re: [PERFORM] Data type to use for primary key > What is the common approach? Should I use directly the product_code as > my ID, or use a sequantial number for speed? (I did the same for the > company_id, this is a 'serial' and not the shor name of the customer. > I just don't know what is usually done. Use a serial : - you can change product_code for a product easily - you can pass around integers easier around, in web forms for instance, you don't have to ask 'should I escape this string ?' - it's faster - it uses less space - if one day you must manage products from another source whose product_code overlap yours, you won't have problems - you can generate them with a serial uniquely and easily ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match