pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: [noob] How to optimize this double pivot query?
Date: Tue, 02 Oct 2012 08:46:11 +0200
Message-ID: <k4e2j6$hc2$1@ger.gmane.org> (raw)
In-Reply-To: <CADf7wwXqQYEgfCdgAuz974EaHhE0-XjeUE2RaTPGskxo8Yfi6Q@mail.gmail.com>
References: <CADf7wwVizZbiQbOp+51HKoDfzYtZRf4trCwJxNniCgqiJDAZ0Q@mail.gmail.com>
	<001201cda03a$49a686d0$dcf39470$@yahoo.com>
	<CADf7wwXqQYEgfCdgAuz974EaHhE0-XjeUE2RaTPGskxo8Yfi6Q@mail.gmail.com>

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








view thread (12+ messages)  latest in thread

Message-ID: <k4e2j6$hc2$1@ger.gmane.org>
Permalink:  ../k4e2j6$hc2$1@ger.gmane.org/
Also on:    postgresql.org/message-id/k4e2j6$hc2$1@ger.gmane.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: spam_eater@gmx.net
  Subject: Re: [noob] How to optimize this double pivot query?
  In-Reply-To: <k4e2j6$hc2$1@ger.gmane.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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