Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect every second row in Mnesia?
    primarykey
    data
    text
    <p>I have a large table in Mnesia and because of various reasons (not important here, say that I am executing the select remotely and the result has to be send over network using some 3rd party libraries) I can't select all rows in one select. I am already splitting the select to only retrieve a specific amount of columns at once.</p> <p>e.g. this is an example of a select to retrieve only specific columns:</p> <pre><code>mnesia:dirty_select([table,[{{table,'$1','_','$3','$4','_','_','_'},[],['$$']}]]). </code></pre> <p>I run that select twice with different set of columns and then combine the results. But now it turned out that one of the columns is also too large to be retrieved in one select. So I'd like to split one large select into two selects, each retrieving only half of rows in that column. Is there an easy way of retrieving, say, every second row? Something like select only odd rows, and then select only even rows? Or maybe a way of retrieving the first half and then the second half of the rows?</p> <p>I tried to select all rows from one of the columns and then use it as an index to retrieve specific rows. This works but takes quite some time to construct the select and then to execute it.</p> <p><strong>EDIT:</strong> Sorry that I didn't stress enough the fact that the select is being executed remotely. I know about iterating over records or accessing the file directly, but the challenge here is that those records in question have to be retrieved using a relatively small amount of commands, and that those commands have to be capable of executing remotely.</p> <p>For example:</p> <ol> <li>Select only the first column (simple single <code>mnesia:dirty_select</code> command).</li> <li>Once the result is retrieved (over network), split it into two sets and use as keys to construct selects to get specific records (each select would contain a long list of keys to retrieve but that's fine as they are simple Erlang terms that can be send over network)</li> <li>Retrieve all rows in two steps using those two sets of keys created in 2.</li> </ol> <p>That works but is not easy and not optimal as it sends quite a lot of data both ways. There may not be an easy solution unless the selects are constructed to take into accounts specific data contained in each column and row (e.g. match all rows with names in the first column starting with letters 'A' to 'M'). I am just not sure what is possible using standard Mnesia commands and was hoping for an easier solution.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload