Write to two or more Mysql tables

Asked

Viewed 58 times

0

Doing this with two or more separate Inserts in the same function is simple, but is there any more correct way that consumes the least amount of resources ? On the platform we are working on, all user actions will be recorded in other tables to later generate statistics.

  • I don’t know any native way of this, since this is not the responsibility of the bank, but the application manage the user logs. Mysql has alternatives to generate querys logs, which is sometimes unfeasible. The only way that comes to mind is the responsibility of the application. http://stackoverflow.com/questions/2488267/how-to-log-user-actions-with-php-and-mysql http://dba.stackexchange.com/questions/33654/mysql-logging-activity-specific-user-or-ip

  • also I do not know a way to do without it being with several Inserts, you can analyze which is best option to record, can store in sessions and time to time record in the bank.

  • I can write to a file of . txt and with time update... I think it is the best option then...

1 answer

0

I don’t know which language you are used to working with, but you could record each of the events in a session (SESSIONS) by storing the id of the event executor, and set a save time to record the event package, through a script with scheduler of type crontab. How could I also create a Procedure (routine) that runs a script in Mysql.

To create a Procedure and run an event script, check below:

  1. Scheduling Mysql events
  2. Create routines in Mysql
  • Use PHP, Sesssions do not slow down? initially thought to add information in . txt and process once a day.... not good ?

  • Sesssions are not slow.

  • You can generate a log.txt as well, it is an option, but you may have memory problems in the same way you send it to mysql. The difference is small.

  • if you don’t want to use Session, use a cookie, or serialize your data to take up space.

  • So Session spends less memory than recording a correct log.txt? got it.

  • Yes. Because it’s execution memory.

  • If you can create txt, you can also create csv sheets, which is more suitable for import.

  • You could also use Lucene from apache.

  • using Session is server-side, cookie is client-side.

  • To be sure which process takes the most resources, simply create a memory consumption and performance test method such as: https://github.com/jokkedk/webgrind

  • It is but to seeing here, I think that Session is not the ideal, I need to recover all the Session at the end and write in the data box at the end of the day... and how would do that? Session is user and does not add information only overwrites....

Show 6 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.