Re: [noob] How to optimize this double pivot query?

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: [noob] How to optimize this double pivot query?
Date: 2012-10-02 06:46:11
Message-ID: k4e2j6$hc2$1@ger.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Samuel Gendler 2012-10-02 09:21:53 Re: [noob] How to optimize this double pivot query?
Previous Message David Johnston 2012-10-02 01:28:48 Re: [noob] How to optimize this double pivot query?