Re: [noob] How to optimize this double pivot query? - Mailing list pgsql-sql

From Thomas Kellerer
Subject Re: [noob] How to optimize this double pivot query?
Date
Msg-id k4e2j6$hc2$1@ger.gmane.org
Whole thread Raw
In response to Re: [noob] How to optimize this double pivot query?  (Robert Buck <buck.robert.j@gmail.com>)
Responses Re: [noob] How to optimize this double pivot query?  (Samuel Gendler <sgendler@ideasculptor.com>)
List pgsql-sql
Robert Buck, 02.10.2012 03:13:
> So as you can probably glean, the tables store performance metric
> data. The reason I chose to use k-v is simply to avoid having to
> create an additional column every time a new metric type come along.
> So those were the two options I thought of, straight k-v and column
> for every value type.
>
> Are there other better options worth considering that you could point
> me towards that supports storing metrics viz. with an unbounded
> number of metric types in my case?
>

Have a look at the hstore module. It's exactly meant for that scenario with the added
benefit that you can index on that column and looking up key names and their values
is blazingly fast then.

That combined with the tablefunc module (which let's you do pivot queries) might
make your queries substantially more readable (and maybe faster as well).

Regards
Thomas







pgsql-sql by date:

Previous
From: David Johnston
Date:
Subject: Re: [noob] How to optimize this double pivot query?
Next
From: mephysto
Date:
Subject: Help in accessing array