- Posts: 32
- Thank you received: 4
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Get an attribute in all [prefix]_tokens_[surveyID] tables
- cavo789
- Topic Author
- Offline
- Junior Member
Less
More
5 years 6 months ago - 5 years 6 months ago #175008
by cavo789
Get an attribute in all [prefix]_tokens_[surveyID] tables was created by cavo789
Hi all
(just for info, I'm French speaking so if it's more convenient to answer in French, it's also perfect for me )
Today I was facing an optimization problem : I need to retrieve a list of teachers and, too, a list of "project leader".
Every survey in our current installation are linked to a classical training session (in a classroom with up to 8 trainers). And training is linked to a module that are grouped into a training project so we've a project leader.
In terms of LimeSurvey, we've one [prefix]_tokens_[surveyID] table by the survey. If we've 1500 surveys... 1500 tables.
My problem concerns the optimization : the project leader name is stored in a field `attribute_12` so, if I need to retrieve the list of all project leaders, I'll need to read 1500 tables.
I can do this with a SELECT attribue_12 from #_tokens_survey1 UNION SELECT attribue_12 from #_tokens_survey2 UNION SELECT attribue_12 from #_tokens_survey3 UNION ...
So making a very big union with all tables.
Even if it works (tested with 20 surveys) it's really not optimized at all.
I was speaking about trainers : their names are stored in fields attributes_2 up to attributes_9 (8 trainers) so my big UNION select will be really big.
Does someone has an idea on how retrieving all my project leader / all my trainers without creating an expensive SQL statement ?
THANKS !
(My current statement is already a stored procedure with a loop)
(just for info, I'm French speaking so if it's more convenient to answer in French, it's also perfect for me )
Today I was facing an optimization problem : I need to retrieve a list of teachers and, too, a list of "project leader".
Every survey in our current installation are linked to a classical training session (in a classroom with up to 8 trainers). And training is linked to a module that are grouped into a training project so we've a project leader.
In terms of LimeSurvey, we've one [prefix]_tokens_[surveyID] table by the survey. If we've 1500 surveys... 1500 tables.
My problem concerns the optimization : the project leader name is stored in a field `attribute_12` so, if I need to retrieve the list of all project leaders, I'll need to read 1500 tables.
I can do this with a SELECT attribue_12 from #_tokens_survey1 UNION SELECT attribue_12 from #_tokens_survey2 UNION SELECT attribue_12 from #_tokens_survey3 UNION ...
So making a very big union with all tables.
Even if it works (tested with 20 surveys) it's really not optimized at all.
I was speaking about trainers : their names are stored in fields attributes_2 up to attributes_9 (8 trainers) so my big UNION select will be really big.
Does someone has an idea on how retrieving all my project leader / all my trainers without creating an expensive SQL statement ?
THANKS !
(My current statement is already a stored procedure with a loop)
Last edit: 5 years 6 months ago by cavo789.
The topic has been locked.
- cavo789
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 32
- Thank you received: 4
5 years 6 months ago #175332
by cavo789
Replied by cavo789 on topic Get an attribute in all [prefix]_tokens_[surveyID] tables
Hi all
Small "up"
Does someone has an idea how to achieve this?
Thanks
Small "up"
Does someone has an idea how to achieve this?
Thanks
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
5 years 6 months ago #175337
by DenisChenu
Ifi need such system maybe add a cron system (php cli is really quicker than web)
Alt solution : create a new table with sid/token/leader and each time a token is saved : add/update this information in the table. But you need to add previous information before. (see github.com/LimeSurvey/LimeSurvey/blob/ma...Log/AuditLog.php#L99 for such plugin usage)
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Get an attribute in all [prefix]_tokens_[surveyID] tables
Personnaly : no …cavo789 wrote: Does someone has an idea how to achieve this?
Ifi need such system maybe add a cron system (php cli is really quicker than web)
Alt solution : create a new table with sid/token/leader and each time a token is saved : add/update this information in the table. But you need to add previous information before. (see github.com/LimeSurvey/LimeSurvey/blob/ma...Log/AuditLog.php#L99 for such plugin usage)
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- cavo789
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 32
- Thank you received: 4
5 years 6 months ago #175437
by cavo789
Replied by cavo789 on topic Get an attribute in all [prefix]_tokens_[surveyID] tables
Thank you DenisChenu.
So let's go in a first instance for creating a cron job.
In a second step perhaps I'll give a try to creating a plugin for LimeSurvey. I'll search the net if there is any tutorial. Thanks for the links on Github; saved in my project's documentation.
Have a nice day!
So let's go in a first instance for creating a cron job.
In a second step perhaps I'll give a try to creating a plugin for LimeSurvey. I'll search the net if there is any tutorial. Thanks for the links on Github; saved in my project's documentation.
Have a nice day!
The topic has been locked.