Skip site navigation (1) Skip section navigation (2)

best db schema for time series data?

From: Louis-David Mitterrand <vindex+lists-pgsql-performance(at)apartia(dot)org>
To: pgsql-performance(at)postgresql(dot)org
Subject: best db schema for time series data?
Date: 2010-11-16 10:50:55
Message-ID: 20101116105055.GA26129@apartia.fr (view raw or flat)
Thread:
Lists: pgsql-performance
Hi,

I have to collect lots of prices from web sites and keep track of their
changes. What is the best option?

1) one 'price' row per price change:

	create table price (
		id_price primary key, 
		id_product integer references product,
		price integer
	);

2) a single 'price' row containing all the changes:

	create table price (
		id_price primary key, 
		id_product integer references product,
		price integer[] -- prices are 'pushed' on this array as they change
	);

Which is bound to give the best performance, knowing I will often need
to access the latest and next-to-latest prices?

Thanks,

Responses

pgsql-performance by date

Next:From: Pavel StehuleDate: 2010-11-16 11:03:29
Subject: Re: best db schema for time series data?
Previous:From: Pavel StehuleDate: 2010-11-16 07:12:03
Subject: Re:

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group