Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've built a multi threaded messaging application in C and I'm currently using a MySQL Memory table to save the session ID, but I'm not sure whether this was a good decision or not.

It works like this, the application sends a message and saves the source session ID in the MySQL table. When the application gets the success response it will remove the session's ID from the MySQL table, or if it received an error response then it will keep the ID to be retried later.

I've built it this way so that I don't need to care about building a data structure by myself, and the Database provides flexibility when it comes to querying it.

Do you think this is appropriate or do I need to use something else? Please note that the application is expecting to handle a large number of transactions/sec.

share|improve this question
Is this a single user application? What if the system crashes - How would you be able to restore the session state? Do you care? – NoChance Mar 26 '12 at 1:12
two or more process are gonna be running on the system – poly Mar 26 '12 at 1:20
up vote 2 down vote accepted

If you can fit everything into available memory why not use one of the many Hash map libraries/templates available for C/C++.

You will get a massive performance boost (no disks, no IO, no parsing no .....) and most of the APIs available are pretty simple to use.

Have a look at this comparison to see which one would best suit your needs.

share|improve this answer

I can share what we did to solve this problem. We built a write-ahead-log, and used an in-memory black/red tree for lookup on a very large set of keys.

The benefits of doing this yourself are many... Encapsulation, less dependencies, performance, no network overhead, etc.

share|improve this answer

You can instead use NDB engine to improve performance and concurrency. High performance replacement of the MySQL Memory storage engine with NDB

share|improve this answer
would you mind explaining more on what it does and why do you recommend it as answering the question asked? "Link-only answers" are not quite welcome at Stack Exchange – gnat Sep 21 '13 at 11:20

If the application is expecting to handle a large number of transactions and the only purpose of the code is processing the session ID, I would suggest you to use hash table. MySQL is so heavy in this situation. In addition, users should install MySQL first when they want to use your application, this will impair your application's user-friendly feature.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.