[erlang-questions] Mnesia record count

Sean Hinde sean.hinde@REDACTED
Tue Nov 27 00:41:05 CET 2007

There is some support for this style of query built into ets via  
ets:select_count(Tab, MatchSpec).

New features in ets have traditionally taken a while to get into  
mnesia, but if your table is disc_copies (or ram_only) then you could  
use this call directly onto the ets backing store of the mnesia table.  
This assumes of course that your query can be expressed as a match spec.

Also it would be worth badgering the OTP guys to bring this very  
useful feature up to the mnesia API


On 26 Nov 2007, at 22:47, Maarten Engelen wrote:

> Hi,
> Currently I'm building an application that needs to do a lot of record
> checking by counting the number of records in a mnesia table based on
> some condition. Mnesia has been a live saver in the development of
> this application, but I can't find a decent solution to the mnesia
> equivalent of COUNT(*) in SQL. I haven't been able to check the number
> of records a certain query would return without reading the complete
> set of results into a list and getting the length of the list.
> I have been looking into the dirty_update_counter function, but this
> doesn't guarantee anything when I have multiple mnesia nodes.
> Any ideas?
> Regards,
> Maarten
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list