8 posts by vutran

Multilevel Index

Suppose we have an index on id column for a table with 10 million rows. The index will eventually become too large that can’t be fit in memory, so we would have to store it somewhere in disk blocks.

The search for an entry in the index would require several disk blocks access. One way to improve this is to use multilevel index. We treat the index just as a database table, and construct another index (outer index) on this index (inner index).

We can repeat this process as many times as needed, until the outer index has small size that can be kept in memory. This would reduce the number of disk accesses significantly.


References: https://www.cs.uct.ac.za/mit_notes/database/htmls/chp11.html#multilevel-indexes

Dictionary Attack

Dictionary attack is a technique used to breach a password-protected system.

This method attempts to guess the correct password by systematically entering each word in a dictionary. This works because many users use normal words in dictionary as their passwords.

There are several ways to prevent this:

  • Account Locking: Lock the account after several unsuccessful attempts
  • Or in the encryption algorithm, the attack can be deterred by adding extra random bits to the end of the value before encryption, such extra bits is referred to as initialization vector, or salt
  • ……….

Memory layout of OS processes


  • Text: The executable code (source code compiled to binary)
  • Data: initialized or uninitialized data
  • Heap: Dynamic allocated memory during program run time
  • Stack: Temporary data storage when invoking functions (local variables, function parameters, return addresses)

The sizes of text and data are fixed.

However, heap and stack can grow and shrink during run time. Each time a function is called, a record contains local variables, function parameters, return addresses is pushed to the stack. When the function finished, that record will be popped from the stack.

Similarly, the heap will grow as memory is dynamically allocated, and shrink when the memory is returned to the system. Notice that stack and heap size can grow toward each other but the OS has to make sure that they won’t overlap one another.

Elixir ETS table

ETS tables are in-memory storage that stores tuples as rows.

ETS is a common way of sharing states between processes/GenServers. But keep in mind that ETS is a datastore, not a database. So the support for transactions is very limited.

Working with ETS tables is done via erlang :ets module

Reference: link