Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id D4C029FBA31 for ; Tue, 5 Jun 2007 20:34:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 15412-08 for ; Tue, 5 Jun 2007 20:34:34 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.177]) by postgresql.org (Postfix) with ESMTP id AD8B69FB6D3 for ; Tue, 5 Jun 2007 20:34:35 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id p76so3880944pyb for ; Tue, 05 Jun 2007 16:34:34 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=Uq6ytB70hp+9/SgXUbpdMsMlc9L3yxA1RQEFsWrSOM90zX3brboAdzNAT4UyLD+XApD6HM/HoNWbcMukkWKAgmjvhbXw+RDWcoQ4QeM5R1rPc5xJwZ5c2hCVVQDm2hgESiFZ4HtZmocwrWK15IOm7ZptCQSs63Mckt+mj0eXd2g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=fTkdVKUn8/w4bOktPrpkPYsk16h1WJp1YHIrc5oEAWNAfE+YR0lThkfH1/1sBKY6y5IY9hw2sMV7f3d6GVdyIYsv+WD76/cbvkzQZVfZvKih+MRoSYzYBsgbhjEYe/LiQd8dY1ngk9oh6SR54iT+s3vac+AkOr5QpqX1XbIqSeg= Received: by 10.35.18.4 with SMTP id v4mr11133981pyi.1181086474457; Tue, 05 Jun 2007 16:34:34 -0700 (PDT) Received: from ?192.168.0.102? ( [66.168.24.69]) by mx.google.com with ESMTP id 40sm2056344nzf.2007.06.05.16.34.30; Tue, 05 Jun 2007 16:34:33 -0700 (PDT) Message-ID: <4665F37A.5040602@gmail.com> Date: Tue, 05 Jun 2007 18:36:26 -0500 From: Peter Koczan User-Agent: Thunderbird 1.5.0.10 (X11/20070306) MIME-Version: 1.0 To: Chris Hoover CC: pgsql-admin@postgresql.org Subject: Re: Help with database change References: <1d219a6f0706050633i47e9724ejc8e8dcc5dbeba2c8@mail.gmail.com> In-Reply-To: <1d219a6f0706050633i47e9724ejc8e8dcc5dbeba2c8@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/32 X-Sequence-Number: 25700 Chris Hoover wrote: > I am doing some research into partitioning my postgres database. > While doing this, I am trying to take the opportunity to improve the > over all database.design. One of the things I am thinking of > implementing would be the use of nullif/coalesce. Our application > tends to send a lot of strings that only contain spaces. While I know > in the long run, the application needs to be fixed, I was thinking > about using nullif and coalesce so the database can just store nulls > in the database and save the space of storing "empty" strings as an > interim fix. > > My question is, how expensive is nullif and coalesce? Can I expect to > see a noticeable impact on performance if I do this? > > Thanks, > > Chris My gut would say that it's not very expensive, unless you're using very expensive regular expressions or already slow functions in expressions with nullif, coalesce. However, you can always run tests yourself. Just generate a bunch of rows with dummy data and put them in a test database. There it's easy enough to benchmark nullif and coalesce on your own terms and see how much overhead they generate. Peter