Our Mnesia DB is running slowly and we think it should be somewhat faster.
So we need to profile it and work out what is happening.
There are a number of options that suggest themselves:
- run fprof and see where the time is going
- run cprof and see which functions are called a lot
However these are both fairly standard performance monitoring style tools. The question is how do I actually do query profiling - which queries are taking the longest times. If we were an Oracle or MySQL shop we would just run a query profiler which would return the sorts of queries that were taking a long time to run. This is not a tool that appears to be available for Mnesia.
So the question is:
- what techniques exist to profile Mnesia
- what tools exist to profile Mnesia - none I think, but prove me wrong :)
- how did you profile your queries and optimise your mnesia database installation
Expanded In The Light Of Discussion
One of the problems with fprof as a profiling tool is that it only tells you about the particular query you are looking at. So fprof tells me that X is slow and I tweak it down to speed it up. Then, low and behold, operation Y (which was fast enough) is now dog slow. So I profile up Y and realise that the way to make Y quick is to make X slow. So I end up doing a series of bilateral trade-offs...
What I actually need is a way to manage multilateral trade-offs. I now have 2 metric shed-loads of actual user activities logged which I can replay. These logs represent what I would like to optimize.
A 'proper' query analyser on an SQL database would be able to profile the structure of SQL statements, eg all statements with the form:
SELECT [fieldset] FROM [table] WHERE {field = *parameter*}, {field = *parameter*}
and say 285 queries of this form took on average 0.37ms to run
They magic answers are when it says: 17 queries of this form took 6.34s to run and did a full table scan on table X, you should put an index on field Y
When I have a result set like this over a representative set of user-activities I can then start to reason about trade-offs in the round - and design a test pattern.
The test pattern would be something like:
- activity X would make queries A, C and C faster but queries E and F slower
- test and measure
- then approve/disapprove
I have been using Erlang long enough to 'know' that there is no query analyser like this, what I would like to know is how other people (who must have had this problem) 'reason' about mnesia optimization.