Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id E79A66342F1 for ; Fri, 11 Jun 2010 05:58:09 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 43905-05 for ; Fri, 11 Jun 2010 08:58:02 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from lo.gmane.org (lo.gmane.org [80.91.229.12]) by mail.postgresql.org (Postfix) with ESMTP id 2A31B633D21 for ; Fri, 11 Jun 2010 05:58:01 -0300 (ADT) Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1ON03n-0007h3-6T for pgsql-performance@postgresql.org; Fri, 11 Jun 2010 10:57:55 +0200 Received: from d220035.adsl.hansenet.de ([80.171.220.35]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 Jun 2010 10:57:55 +0200 Received: from tim by d220035.adsl.hansenet.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 11 Jun 2010 10:57:55 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-performance@postgresql.org To: pgsql-performance@postgresql.org connect(): No such file or directory From: Tim Landscheidt Subject: Re: Analysis Function Date: Fri, 11 Jun 2010 08:57:43 +0000 Organization: Lines: 43 Message-ID: References: <4C119B3E.3090608@squeakycode.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: d220035.adsl.hansenet.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:SxHhTl/FvX2bNHAAuiNV+1yyhKw= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.79 tagged_above=-10 required=5 tests=BAYES_50=0.8, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/201 X-Sequence-Number: 39057 David Jarvis wrote: > [...] > Yes. Here are the variations I have benchmarked (times are best of three): > Variation #0 > -no date field- > Explain: http://explain.depesz.com/s/Y9R > Time: 2.2s > Variation #1 > date('1960-1-1') > Explain: http://explain.depesz.com/s/DW2 > Time: 2.6s > Variation #2 > date('1960'||'-1-1') > Explain: http://explain.depesz.com/s/YuX > Time: 3.1s > Variation #3 > date(extract(YEAR FROM m.taken)||'-1-1') > Explain: http://explain.depesz.com/s/1I > Time: 4.3s > Variation #4 > to_date( date_part('YEAR', m.taken)::text, 'YYYY' ) + interval '0 months' + > interval '0 days' > Explain: http://explain.depesz.com/s/fIT > Time: 4.4s > What I would like is along Variation #5: > *PGTYPESdate_mdyjul(taken_year, p_month1, p_day1)* > Time: 2.3s > I find it interesting that variation #2 is half a second slower than > variation #1. > [...] Have you tested DATE_TRUNC()? Tim