pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedindexing timestamp fields
5+ messages / 3 participants
[nested] [flat]
* indexing timestamp fields
@ 2003-10-15 15:56 teknokrat <teknokrat@yahoo.com>
2003-10-15 16:21 ` Re: indexing timestamp fields Christopher Browne <cbbrowne@libertyrms.info>
0 siblings, 1 reply; 5+ messages in thread
From: teknokrat @ 2003-10-15 15:56 UTC (permalink / raw)
To: pgsql-sql
Is it a good idea to index timestamp fields? what about date fields in
general?
thanks
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: indexing timestamp fields
2003-10-15 15:56 indexing timestamp fields teknokrat <teknokrat@yahoo.com>
@ 2003-10-15 16:21 ` Christopher Browne <cbbrowne@libertyrms.info>
2003-10-15 20:25 ` Re: indexing timestamp fields teknokrat <teknokrat@yahoo.com>
0 siblings, 1 reply; 5+ messages in thread
From: Christopher Browne @ 2003-10-15 16:21 UTC (permalink / raw)
To: pgsql-sql
teknokrat <teknokrat@yahoo.com> writes:
> Is it a good idea to index timestamp fields? what about date fields in
> general?
If you need to order by a timestamp, then it can be worthwhile.
If that timestamp can be null, and is rarely populated, then you might
get a _big_ benefit from creating a partial index as with:
create index by_some_date on my_table(some_date) where some_date is
not null;
--
"cbbrowne","@","libertyrms.info"
<http://dev6.int.libertyrms.com/;
Christopher Browne
(416) 646 3304 x124 (land)
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: indexing timestamp fields
2003-10-15 15:56 indexing timestamp fields teknokrat <teknokrat@yahoo.com>
2003-10-15 16:21 ` Re: indexing timestamp fields Christopher Browne <cbbrowne@libertyrms.info>
@ 2003-10-15 20:25 ` teknokrat <teknokrat@yahoo.com>
2003-10-15 21:31 ` Re: indexing timestamp fields Christopher Browne <cbbrowne@libertyrms.info>
2003-10-16 16:56 ` Re: indexing timestamp fields Bruno Wolff III <bruno@wolff.to>
0 siblings, 2 replies; 5+ messages in thread
From: teknokrat @ 2003-10-15 20:25 UTC (permalink / raw)
To: pgsql-sql
Christopher Browne wrote:
> teknokrat <teknokrat@yahoo.com> writes:
>
>>Is it a good idea to index timestamp fields? what about date fields in
>>general?
>
>
> If you need to order by a timestamp, then it can be worthwhile.
>
> If that timestamp can be null, and is rarely populated, then you might
> get a _big_ benefit from creating a partial index as with:
>
> create index by_some_date on my_table(some_date) where some_date is
> not null;
I have a lot of queries of the " where timestamp < some date " type and
was wondering if an index would improve performance. None of the
timestamps are null and they are always populated
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: indexing timestamp fields
2003-10-15 15:56 indexing timestamp fields teknokrat <teknokrat@yahoo.com>
2003-10-15 16:21 ` Re: indexing timestamp fields Christopher Browne <cbbrowne@libertyrms.info>
2003-10-15 20:25 ` Re: indexing timestamp fields teknokrat <teknokrat@yahoo.com>
@ 2003-10-15 21:31 ` Christopher Browne <cbbrowne@libertyrms.info>
1 sibling, 0 replies; 5+ messages in thread
From: Christopher Browne @ 2003-10-15 21:31 UTC (permalink / raw)
To: pgsql-sql
teknokrat <teknokrat@yahoo.com> writes:
> Christopher Browne wrote:
>
>> teknokrat <teknokrat@yahoo.com> writes:
>>
>>>Is it a good idea to index timestamp fields? what about date fields in
>>>general?
>> If you need to order by a timestamp, then it can be worthwhile.
>> If that timestamp can be null, and is rarely populated, then you
>> might
>> get a _big_ benefit from creating a partial index as with:
>> create index by_some_date on my_table(some_date) where some_date is
>> not null;
>
> I have a lot of queries of the " where timestamp < some date " type
> and was wondering if an index would improve performance. None of the
> timestamps are null and they are always populated
There isn't a single straight answer on this.
It _might_ help; it might not.
- It might be that adding "timestamp" to some existing index would be
better still.
- If the table is real big, and the "ts < other_ts" doesn't restrict
things very much, then you may merely sit in between an index scan
that touches every page of the table and a Seq Scan that does the
same.
Try creating the index, and do some EXPLAIN ANALYZE queries to see
what happens; that should give you an idea as to how effective this
is.
--
output = ("cbbrowne" "@" "libertyrms.info")
<http://dev6.int.libertyrms.com/;
Christopher Browne
(416) 646 3304 x124 (land)
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: indexing timestamp fields
2003-10-15 15:56 indexing timestamp fields teknokrat <teknokrat@yahoo.com>
2003-10-15 16:21 ` Re: indexing timestamp fields Christopher Browne <cbbrowne@libertyrms.info>
2003-10-15 20:25 ` Re: indexing timestamp fields teknokrat <teknokrat@yahoo.com>
@ 2003-10-16 16:56 ` Bruno Wolff III <bruno@wolff.to>
1 sibling, 0 replies; 5+ messages in thread
From: Bruno Wolff III @ 2003-10-16 16:56 UTC (permalink / raw)
To: teknokrat <teknokrat@yahoo.com>; +Cc: pgsql-sql
On Wed, Oct 15, 2003 at 21:25:17 +0100,
teknokrat <teknokrat@yahoo.com> wrote:
>
> I have a lot of queries of the " where timestamp < some date " type and
> was wondering if an index would improve performance. None of the
> timestamps are null and they are always populated
Unless that query returns only a small fraction of the table (which would
be unusual for a before some date restriction) or you order by the date,
an index probably won't help.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2003-10-16 16:56 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-10-15 15:56 indexing timestamp fields teknokrat <teknokrat@yahoo.com>
2003-10-15 16:21 ` Christopher Browne <cbbrowne@libertyrms.info>
2003-10-15 20:25 ` teknokrat <teknokrat@yahoo.com>
2003-10-15 21:31 ` Christopher Browne <cbbrowne@libertyrms.info>
2003-10-16 16:56 ` Bruno Wolff III <bruno@wolff.to>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox