[erlang-questions] Fetching several ets keys

Ahmed Omar spawn.think@REDACTED
Thu Feb 9 12:09:21 CET 2012


Hynek,
Yes you are right, if the table is big full scan is not a good idea.

2012/2/9 ori brost <oribrost@REDACTED>

> The question is whether there is any way that I can avoid the
> "erlang-to-c call" cost and do these 4 lookups (i.e. with one ets call
> do lookup for all 4).
>
> On Thu, Feb 9, 2012 at 1:00 PM, Hynek Vychodil <hynek@REDACTED> wrote:
> > This code will cause table full scan which usually will be far slower
> than just
> > [ V || K <- ["A","B","C","D"], V <- ets:lookup(Tid, K) ]
> > except very small tables full scan will not be good idea.
> >
> > On Thu, Feb 9, 2012 at 11:49 AM, Ahmed Omar <spawn.think@REDACTED>
> wrote:
> >> ets:select(Tid, [{{'$1','$2'},[{'==','$1',X}],['$_']}|| X<-
> >> ["A","B","C","D"]]).
> >>
> >>
> >> On Thu, Feb 9, 2012 at 11:11 AM, dmitry kolesnikov <
> dmkolesnikov@REDACTED>
> >> wrote:
> >>>
> >>> You could try
> >>> ets:select or qlc interface.
> >>>
> >>> It table is not big enough then qlc and custom fold function would
> work:
> >>>
> >>> Q=qlc:q([ X || X <- ets:table(mytab)]),
> >>> qlc:fold(FoldFun, [], Q)
> >>>
> >>> Best Regards,
> >>> Dmitry >-|-|-*>
> >>>
> >>>
> >>> On 9.2.2012, at 11.40, ori brost <oribrost@REDACTED> wrote:
> >>>
> >>> > Is there any way in ets to fetch values for several keys in 1 call?
> >>> > i.e. something like
> >>> >
> >>> > ets:multi_fetch(Tid, ["A","B","C","D"]) % will fetch all entries with
> >>> > keys A, B, C, D
> >>> > _______________________________________________
> >>> > erlang-questions mailing list
> >>> > erlang-questions@REDACTED
> >>> > http://erlang.org/mailman/listinfo/erlang-questions
> >>> _______________________________________________
> >>> erlang-questions mailing list
> >>> erlang-questions@REDACTED
> >>> http://erlang.org/mailman/listinfo/erlang-questions
> >>
> >>
> >>
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://erlang.org/mailman/listinfo/erlang-questions
> >>
> >
> >
> >
> > --
> > Hynek Vychodil
> > BI consultant
> >
> > GoodData
> > náměstí 28. října 1104/17, 602 00, Brno - Černá Pole
> > Office:   +420 530 50 7704
> > E-mail:  hynek@REDACTED
> > Web:     www.gooddata.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120209/1e265010/attachment.htm>


More information about the erlang-questions mailing list