Fortu
Fortu

Reputation: 214

Which is more expensive to the RAM, A query list comprehension, or a mnesia index_read?

I am trying to read from a fragmented mnesia table that is likely to hold a very large number of records in the near future. These reads may also be by other keys other than the primary key of the table.

Which of the two options is more efficient? A Query List comprehension, or a mnesia index read?

Upvotes: 4

Views: 267

Answers (1)

Muzaaya Joshua
Muzaaya Joshua

Reputation: 7836

Well, indices will require more Disk space. For each table fragment, mnesia will create a separate index file. However, index reads are more efficient from experience.

QLC will consume more memory at run time especially when the results of a query are so many. This would require you to use Query Cursors. I advise you to use Index read. Index read is not expensive at all to RAM because its a normal read though mnesia has to consult the index file first. QLC is good when it comes to doing complex table relationships and evaluations of return values in a batch. However, it introduces Processing costs and Memory when the results are too many. Note that QLC uses mnesia:select/1,2 and 4 (which specific one, am not sure) but i know that select is an operation that makes mnesia traverse the whole table in serach for records.

Mnesia Index read is better than Query List comprehension

Upvotes: 5

Related Questions