We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

MyISAM to InnodDB storage system change - better site performance | Forum

Topic location: Forum home » Support » General Questions
Peter
Peter Feb 3 '15
I just changed tables in DB from MyISAM to InnoDB and now I have better performance.

When I used MyISAM, if someone enter the dashboard, that lock all other users requests and sometimes site crash into 50x error. Now everything works fine.

Do you have any experience with it? Has InnoDB storage system also any disadvantages? (sorry english is not my native language)
The Forum post is edited by Peter Feb 3 '15
ross Team
ross Feb 4 '15
In terms of the software performance, there's no difference which one to use. The fact that you have switched to InnoDB has nothing to do with the crashing and locking users requests. 

The disadvantage of InnoDB, that you will have to backup more often, also InnoDB has its own separate storage place (file), in case it is lost, you won't be able to restore it. In this regard MyISAM has more flexible restoration workflow. 


you can google more detailed info. 

moonwald
moonwald May 6 '15
Hi Ross
in this case the problem is that I'm not able to do queries with usual way as it happens with foreign keys
so which is the better way for example to do a query where profile question  is "music" inside profile question section "Interests" ?  and how can I do a select for a specific user? (with interests, date_registration and so on?

Anyway is it possible to pass to a version with foreign keys?
'cause we ahve all informations inside the same table : ow_base_question_data and it seems difficult to retrieve informations for specific questions or specific users.

Thanks

Moonwald

dave Leader
dave May 6 '15
you might want to read this before changing to InnoDB


http://www.oxwall.org/forum/topic/35946?page=1#post-145108


Peter
Peter May 6 '15
Hi, I changed DB engine to InnoDB, and I note a significant improvement in the speed of queries, because InnoDb support "row level locking" - support simultaneous write access by multiple sessions, making them suitable for multi-user, highly concurrent.

MyISAM uses "tablelevel locking" - allowing only one session to update those tables at a time. /it makes "waiting for table lock" -and that slows the query.


The Forum post is edited by Peter May 6 '15
Taissa Team
Taissa May 7 '15
moonwald,  does the dave's answer help you to find an answer to your question ?
Peter, do you have more questions about database and connected to this topic?

moonwald
moonwald May 14 '15
Thanks Taissa

But in this case is it necessary to change ow_base_dao.sql with foreign keys?

In the case of passage to InnoDB is it possible to add inner join for searching users interests?

I mean: is it possible to add join (ow_base_user, ow_base_avatar, ow_base_question) inside ow_base_dao.sql OR is it not necessary?

Is it possible to execure query with actual ISAM for the same purpose
to do select in order to check all base_question divided by sub_questions (example: food -> chinese food?)

Thanks

Moonwald



Taissa Team
Taissa May 18 '15
moonwald, could you please clarify why you need to use the "foreign keys".
Where did you get the ow_base_dao.sql file?

So, if you need to get the these values: match_sex(Looking for), realname, birthdate for all users you may try running this query:

SELECT u.username, d.`intValue` as 'match_sex', d1.`textValue` as 'realname', d2.`dateValue` as 'birthdate'  FROM ow_base_user u 
INNER JOIN ow_base_question_data d ON ( u.id = d.userId and d.questionName = 'match_sex' )
INNER JOIN ow_base_question_data d1 ON ( u.id = d1.userId and d1.questionName = 'realname' )
INNER JOIN ow_base_question_data d2 ON ( u.id = d2.userId and d2.questionName = 'birthdate' )

The Forum post is edited by Taissa May 18 '15
moonwald
moonwald May 27 '15
Thank you very much Taissa

maybe I need more time in order to understand the relationship among ow_base_question_data, ow_base_question_value and ow_base_question


Infact I do not understand 'cause we have the columns "questionName" and  ow_base_question."name" not in clear mode: we have great varchars /values full of numbers and characters so it's difficult to retrieve the values that we see on the pages..


Moonwald

Taissa Team
Taissa May 28 '15
Moonwald,  I am really sorry but I didn't get the idea of your request. Can you either rephrase it or give me more details and examples for better understanding?

moonwald
moonwald May 28 '15
Which is the relationship between ow_base_question_data and ow_base_question_value?


For example I have into ow_base_question_value VALUES (questionName) without a precise meaning


INSERT INTO `ow_base_question_value` VALUES (309,'4971fc7002dca728f9a7f2a417c5284e',512,4);INSERT INTO `ow_base_question_value` VALUES (310,'match_sex',1,0);INSERT INTO `ow_base_question_value` VALUES (311,'match_sex',2,1);
I have the same into ow_base_question_data
ow_base_question_datado you know why?

Taissa Team
Taissa Jun 1 '15
Moonwald, here is the list of tables: 
ow_base_question  - here the list of questions.
ow_base_question_data - here the questions and data users selected are saved.
ow_base_question_value - here is the data for questions of "multiple choice" type is saved ( for example list, multi list, radio button). Values of questions themselves ( for example  d68489df439fe45427e305a0e2dbe349_1 -  has a value "USA") are saved under languages.


moonwald
moonwald Jun 8 '15
But Taissa,
why the values of questions themselves (ow_base_question_value) are in not so clear/understandable meaning? Why was this value inserted with this code "d68489df439fe45427e305a0e2dbe349_1" at the place of "USA" directly ?

And why these values are saved in the same column? How is it possible to manage better the values of different multi list? In different columns
If the question food has the multi list : chinese, japanese, indian why does it put in a same column all these values? and in code not clear as you mentioned with the example:

d68489df439fe45427e305a0e2dbe349_1 -   value "USA"?



Taissa Team
Taissa Jun 9 '15
Moonwald, it is normal, the system generates hash values for custom created something (account type, profile question etc. ) or what can be edited. This was done to optimize the data search and data storage.
If you will look in the languages section you'll see that a key has the value. Using your example find the "chinese" in the Language section and you will see that the key includes the hash value.
moonwald
moonwald Jun 20 '15
So Taissa,

taking your past query:SELECT u.username, d.`intValue` as 'match_sex', d1.`textValue` as 'realname', d2.`dateValue` as 'birthdate'  FROM ow_base_user u  
INNER JOIN ow_base_question_data d ON ( u.id = d.userId and d.questionName = 'match_sex' ) 
INNER JOIN ow_base_question_data d1 ON ( u.id = d1.userId and d1.questionName = 'realname' ) 
INNER JOIN ow_base_question_data d2 ON ( u.id = d2.userId and d2.questionName = 'birthdate' ) 
what does it need to add in this query in order to know value/values the key/keys associated with a specific multiple choice and the relative section profile question of all users?







Taissa Team
Taissa Jun 23 '15
Moonwald, you can't do it by using only SQL queries you will need to use php code like this one, for example:
for( $i = 0 ; $i < 31; $i++ )
{
    $val = pow( 2, $i );
    if ( (int)$sex & $val  )
    {
        $sexValue .= BOL_QuestionService::getInstance()->getQuestionValueLang('sex', $val) . ', ';
    }
}
So if I understand you correctly your task requires a plugin creating  and  involves the use  of different functions and methods, for example these ones:
-base.questions_field_init
-base.questions_save_data
-base.questions_get_data
base.question.search_sql.

And also use the methods of the language_service.php file.
moonwald
moonwald Jun 26 '15
Taissa,
so is it not possible to do a query in order to know how many and who is the user that filled the key/value of aspecific multiple choice values of a relative section profile question?

:-(

Thanks

Moonwald
Taissa Team
Taissa Jun 30 '15
Moonwald, here is the simple query example how you may get the users ID list: SELECT userId FROM `ow_base_question_data` WHERE `questionName` = 'question' AND `intValue` & {intValue}

where `questionName` is the required profile question hash value, for example field_2e5aeef45baae9a386bda11d8a653d76
and {intValue} - the multiple choice value from ow_base_question_value table or you may see it in language section.

so, for example you should get such a request:

SELECT `userId` FROM `ow_base_question_data` WHERE `questionName` = 'field_2e5aeef45baae9a386bda11d8a653d76' AND `intValue` & 2

And then you will need to use the following services to work with user list:
BOL_UserService
BOL_QuestionService
moonwald
moonwald Jul 22 '15
One curiosity, Taissa

why the necessity to insert all the informations about users interests into a unique table as
ow_base_question_data?

this table cannot be so great!

For example 'questionName' is repeated multiple times
maybe was it better to create a relational table where to insert the link to the field question Name?

Thanks

Moonwald
moonwald
moonwald Jul 25 '15
so for the migration to other database
in order to have the same questions with multiple choice in the section QUESTIONS INTERESTS area
is it only necessary to make the dump of these tables?

ow_base_language_key
ow_base_question_data
ow_base_question_value
ow_base_question

Kind Regards

Moonwald

Pages: 1 2 »