[erlang-questions] Mnesia equivalent of SQL NOT IN

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Sun Feb 19 22:15:27 CET 2012


On 2/19/12 3:46 PM, Ward Bekker wrote:
>
> Hi,
>
> I have two records:
>
> |-record(foo, {timestamp, name}).
> -record(bar, {timestamp, name}).
> |
>
> And I would like to execute a Mnesia query that mimics the following 
> SQL query
>
> |SELECT f.* FROM foo f WHERE f.timestamp NOT IN ( SELECT b.timestamp FROM boo b)
> |
>
> What would be an efficient Mnesia equivalent?
>
>
It depends on which indexes you have in your fine SQL database :) But 
writing a QLC (Query List Comprehension) containing a subselect should 
be possible without too much work. The question is if you get a decent 
efficiency out of it. Which is where the indexes comes into play. If you 
need this a lot, then you may need to organize your data in a shape that 
makes it efficient. The point of mnesia is that it works much like a 
modern K/V (NoSQL) store in its performance metrics - so you need to 
think about the shape of data to get it to run fast.

-- 
Jesper Louis Andersen
   Erlang Solutions Ltd., Copenhagen, DK

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120219/dae941bd/attachment.htm>


More information about the erlang-questions mailing list