[erlang-questions] How to select a record with an attribute which is maximal in mnesia table?

Ulf Wiger <>
Wed Apr 14 16:24:58 CEST 2010


Mnesia disc_copies tables can be ordered_set. It's only disc_only_copies
that can't.

Disc_copy tables are essentially just spooled to disk, so the
organization in RAM (hash or btree) is just a function of how
the ets table holding the data in RAM is configured.

BR,
Ulf W

Nicholas Frechette wrote:
> Just keep in mind mnesia doesn't support disk copies of ordered sets so
> you'll have to serialize to disk manually, either on every update,
> periodically or on app exit (tricky in cases where your app core dumps).
> 
> Alternatively, you can simply write to a flat file on the side of your
> mnesia table in memory (or just go with the flat file) and then on app
> start, open the file, seek to the end - size of your record (hopefully fixed
> size...) and voila.
> 
> 2cents.
> Nicholas
> 
> On Wed, Apr 14, 2010 at 9:22 AM, Bengt Kleberg
> <>wrote:
> 
>> Greetings,
>>
>> Would it be ok for you to have the date/time as record key? If you have
>> that and an ordered_set then the last record is just that, last.
>>
>>
>> bengt
>>
>> On Wed, 2010-04-14 at 11:34 +0200, 钱晓明 wrote:
>>> Hi, I want to select a record with an attribute which is maximal from
>> mnesia
>>> table, so should I use qlc?
>>> For example, I have to insert a record into a table every 5 minutes, and
>>> when my program start up, it should read the last record to get some
>>> information.
>>> So how can I achieve this?
>>>
>>> Thanks!
>>
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:
>>
>>
> 


-- 
Ulf Wiger
CTO, Erlang Solutions Ltd, formerly Erlang Training & Consulting Ltd
http://www.erlang-solutions.com

---------------------------------------------------

---------------------------------------------------

WE'VE CHANGED NAMES!

Since January 1st 2010 Erlang Training and Consulting Ltd. has become ERLANG SOLUTIONS LTD.

www.erlang-solutions.com



More information about the erlang-questions mailing list