Re: [PERFORM] Most efficient way of querying M 'related' tables where N out of M may contain the key

2015-08-21 Thread David G. Johnston
On Fri, Aug 21, 2015 at 8:07 AM, Stephane Bailliez sbaill...@gmail.com wrote: On Thu, Aug 20, 2015 at 8:19 PM, David G. Johnston david.g.johns...@gmail.com wrote: ​SELECT [...] FROM (SELECT reference_id, [...] FROM table_where_referenced_id_is_a_pk WHERE reference_id EXISTS/IN/JOIN)​

Re: [PERFORM] Most efficient way of querying M 'related' tables where N out of M may contain the key

2015-08-21 Thread Stephane Bailliez
On Thu, Aug 20, 2015 at 8:19 PM, David G. Johnston david.g.johns...@gmail.com wrote: ​SELECT [...] FROM (SELECT reference_id, [...] FROM table_where_referenced_id_is_a_pk WHERE reference_id EXISTS/IN/JOIN)​ ​src ​LEFT JOIN type1 USING (reference_id) LEFT JOIN type2 USING (reference_id)

Re: [PERFORM] Most efficient way of querying M 'related' tables where N out of M may contain the key

2015-08-20 Thread David G. Johnston
On Thu, Aug 20, 2015 at 8:03 PM, Stephane Bailliez sbaill...@gmail.com wrote: Pretty bad subject description... but let me try to explain. I'm trying to figure out what would be the most efficient way to query data from multiple tables using a foreign key. ​SELECT [...] FROM (SELECT

[PERFORM] Most efficient way of querying M 'related' tables where N out of M may contain the key

2015-08-20 Thread Stephane Bailliez
Pretty bad subject description... but let me try to explain. I'm trying to figure out what would be the most efficient way to query data from multiple tables using a foreign key. Right now the table design is such that I have multiple tables that share some common information, and some specific