Re: schema advice for event stream with tagging and filtering

From: Chris Withers <chris(at)simplistix(dot)co(dot)uk>
To: Ilya Kazakevich <Ilya(dot)Kazakevich(at)JetBrains(dot)com>, 'Postgresql General' <pgsql-general(at)postgresql(dot)org>
Subject: Re: schema advice for event stream with tagging and filtering
Date: 2016-08-16 13:37:56
Message-ID: 0a47418c-da6e-b928-86b2-0c4917502303@simplistix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 16/08/2016 14:29, Ilya Kazakevich wrote:
> Hi,
>
>> An event is a row with a primary key along the lines of (colo, host,
>> category) and an associated set of tags, where each tag has a type and a value
>> (eg: {"color": "red", "owner": "fred", "status": "open"...}).
>
> What about simple table with several columns and hstore field for tags?

Interesting!

> You may also normalize it (move hosts and categories to separate table).

Why? These form part of the primary key for the event...

> indexes should help you with fast filtering, or you may load data from this table to denormalized olap table once a day and build index there to speed-up queries.

What kind of index is recommended here? The kind of queries would be:

- show me a list of tag types and the count of the number of events of
that type

- show me all events that have tag1=x, tag2=y and does not have tag3

cheers,

Chris

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ilya Kazakevich 2016-08-16 14:10:45 Re: schema advice for event stream with tagging and filtering
Previous Message Ilya Kazakevich 2016-08-16 13:29:54 Re: schema advice for event stream with tagging and filtering