Date + Days = Date

From: Bob Dusek <bobd(at)palaver(dot)net>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Date + Days = Date
Date: 1999-02-04 02:59:22
Message-ID: Pine.LNX.3.96.990203213514.196H-100000@temp.palaver.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hey all,

Thanks, everyone, for the info you gave me on the cost of joins and
GEQO. That stuff was helpful and I'm working on solving my "slowness"
problems right now.

And, I've stumbled upon another question. I've noticed that date comparison
seems to be somewhat slow, especially when sifting through an entire
electronic inventory trying to find inventory that is, say, more than one
month old. What I do in my query is something like:

select info from tables where item.date <= max.date and item.date >= min.date;

I also do a query that is something like this:

select 'now'::date - item.date as days_old from item where ......;

This sort of date comparison may not be a major bottleneck, but to my
understanding this sort of date comparison is slower than integer comparison.
(Does anyone have any data on that?)

So, what I might do is go to a "day" tracking system, rather than a
"date" tracking system. The very first date that an inventory item
was entered into the system will be day 1. The next day = day 2, etc...

PostgreSQL's "select date('now'::date + 400)" functionality allows me
to do this, since it returns the actual date 400 days from right now.

Is this functionality accurate, in terms of leap year quirks?

TIA,

Bob

Browse pgsql-general by date

  From Date Subject
Next Message Petr Hubeny 1999-02-04 09:43:03 PostgreSQL 6.4.2 locale regexp and like problem
Previous Message Bruce Momjian 1999-02-03 23:11:00 Re: [GENERAL] EXPLAIN