Re: Query Performance with Indexes on Integer type vs. Date type. - Mailing list pgsql-performance

From Maciek Sakrejda
Subject Re: Query Performance with Indexes on Integer type vs. Date type.
Date
Msg-id BANLkTi=14-tJAZO8QVf8ThHmmkcr_VqBFw@mail.gmail.com
Whole thread Raw
In response to Query Performance with Indexes on Integer type vs. Date type.  (Dhimant Patel <drp4kri@gmail.com>)
List pgsql-performance
> This makes me wonder would it make any good to create additional  column of Integer type and update it as data gets
addedand use this integer column for all ordering purposes for my sqls - or should I not hasitate using Date type
straightinto my sql for ordering? 

Keep in mind what Michael A. Jackson (among others) had to say on
this: "The First Rule of Program Optimization: Don't do it. The Second
Rule of Program Optimization (for experts only!): Don't do it yet."
For one thing, adding an extra column to your data would mean more
data you need to cram in the cache as you query, so even if the *raw*
integer versus date ordering is faster, the "optimization" could still
be a net loss due to the fatter tuples. If you're willing to live with
*only* integer-based dates, that could help, but that seems
exceptionally painful and not worth considering unless you run into
trouble.

> Better yet, is there anyway I can verify impact of ordering on Date type vs. Integer type, apart from using \timing
andexplain plan? 

Remember to use explain analyze (and not just explain) when validating
these sorts of things. Explain is really just a guess. Also remember
to ensure that stats are up to date before you test this.

---
Maciek Sakrejda | System Architect | Truviso

1065 E. Hillsdale Blvd., Suite 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: Query Performance with Indexes on Integer type vs. Date type.
Next
From: "Kevin Grittner"
Date:
Subject: Re: Query Performance with Indexes on Integer type vs. Date type.