Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id EADDB1337B92 for ; Wed, 27 Apr 2011 13:12:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 36291-04 for ; Wed, 27 Apr 2011 16:12:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 942E41337B49 for ; Wed, 27 Apr 2011 13:11:59 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p3RGBwdn017018; Wed, 27 Apr 2011 12:11:58 -0400 (EDT) To: Dhimant Patel cc: pgsql-performance@postgresql.org Subject: Re: Query Performance with Indexes on Integer type vs. Date type. In-reply-to: References: Comments: In-reply-to Dhimant Patel message dated "Wed, 27 Apr 2011 11:28:19 -0400" Date: Wed, 27 Apr 2011 12:11:57 -0400 Message-ID: <17017.1303920717@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/370 X-Sequence-Number: 43432 Dhimant Patel writes: > From my initial read on documentation I believe internally a date type is > represented by integer type of data. This makes me wonder would it make any > good to create additional column of Integer type and update it as data gets > added and use this integer column for all ordering purposes for my sqls - or > should I not hasitate using Date type straight into my sql for ordering? Don't overcomplicate things. Comparison of dates is just about as fast as comparison of integers, anyway. regards, tom lane