Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 7F5039F9EDF; Mon, 20 Aug 2007 22:35:19 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 01726-01; Mon, 20 Aug 2007 22:35:09 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mtao04.charter.net (mtao04.charter.net [209.225.8.178]) by postgresql.org (Postfix) with ESMTP id 987729F9E23; Mon, 20 Aug 2007 22:35:14 -0300 (ADT) Received: from aa02.charter.net ([10.20.200.154]) by mtao04.charter.net (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20070821013504.VQOE23660.mtao04.charter.net@aa02.charter.net>; Mon, 20 Aug 2007 21:35:04 -0400 Received: from [10.0.1.2] (really [66.188.165.91]) by aa02.charter.net with ESMTP id <20070821013504.NXEZ26124.aa02.charter.net@[10.0.1.2]>; Mon, 20 Aug 2007 21:35:04 -0400 In-Reply-To: References: <46C9E9A7.1080409@yahoo.com.br> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <311DDC69-7101-4591-99EC-8FFF4365C53B@seespotcode.net> Cc: novice , pgsql-general@postgresql.org, pgsql-sql@postgresql.org, "Osvaldo Rosario Kussama" Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: [SQL] Join query help Date: Mon, 20 Aug 2007 20:35:02 -0500 To: Michael Glaesemann X-Mailer: Apple Mail (2.752.2) X-Chzlrs: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/1252 X-Sequence-Number: 119101 On Aug 20, 2007, at 20:27 , Michael Glaesemann wrote: > Note: record_id is in integer, yet you're quoting the value ('1'). > This causes the server to cast the text value to an integer. Here > it's not going to cause much of a problem, just a couple CPU > cycles. In table definitions (and possibly queries?) it can cause > the server to ignore otherwise usable indexes when planning > queries. (I see below your other inserts also quote integer values: > you should drop the quotes there as well.) Some clarification: what I meant by "table definitions" is if you're actually defining text columns that reference integer columns. For example: CREATE TABLE foos (foo_id INTEGER PRIMARY KEY, foo text NOT NULL UNIQUE); CREATE TABLE bars (bar text PRIMARY KEY, foo_id text NOT NULL REFERENCES foos (foo_id)); Michael Glaesemann grzm seespotcode net