Fwd: What is the best way to model attributes relations ? - Mailing list pgsql-general

From amihay gonen
Subject Fwd: What is the best way to model attributes relations ?
Date
Msg-id CAKb+SBV9nC8H_YE9Zb1Jt5uPrxdFnCNCamG06QAXLi-aefh6DA@mail.gmail.com
Whole thread Raw
In response to What is the best way to model attributes relations ?  (amihay gonen <agonenil@gmail.com>)
List pgsql-general



---------- Forwarded message ---------
From: amihay gonen <agonenil@gmail.com>
Date: Thu, 15 Jan 2015 13:37
Subject: What is the best way to model attributes relations ?
To: pgsql-general <pgsql-general@postgresql.org>


I need to support the following queries :
    1. give all documents where attrib X='value'
    2. give me all documents where attib X='value' and attrib Y='value2'


the distinct  attributes if about 10,000,000,000  on about 10 difference type (X,Y etc), so in average 1000 M for each.
each attribute may appear in 10-20 documents .

The model has to optimized to fast read & write.

Here are two model I was thinking of :

Option 1 : Using RDBMS (PG)

One big table (partition by type) , index on value , index on document id ,  type: 
attr type, attr value , document id  .  

For query 1 - it a simple query .
For query 2 - do self join 


Option 2 : 

Same on option 1 but to hold all documents id in one string :
for example :
   'host', 'myhost', apper in ' 3,5,6,7 ,8'

For query 2 : 
do one query - with or , for example : select document ids from ... where (attr='X' and value='Y') 
                                       union 
                                        select document ids from ... where (attr='X' and value='Y')  
and the do set merging 

Other options :
   ? using btree_gin ? 

   elasticsearch ? 

pgsql-general by date:

Previous
From: amihay gonen
Date:
Subject: What is the best way to model attributes relations ?
Next
From: M Tarkeshwar Rao
Date:
Subject: can you have any idea about toast missing chunk issu resolution