Query SQL queries during production?

I have a dilemma about whether SQL queries should be logged during production.

I do not know how slowly files are written in PHP. Some tests may probably give some answers, but I wanted to see what you guys think before.

What does or does not make the process slow? Or what can it depend on?

+3
source share
4 answers

Most databases have built-in options for query logging and slow query logging, so you do not need to log in through PHP. You do not have to log all requests during the production process unless you have problems, and this is part of the troubleshooting process. You can and should record slow requests so you can see what can slow down your production site.

If your infrastructure supports it, you can only register requests if a page takes a certain amount of time to create (this is what I do). Then you log in conditionally and you may find an excessive number of running requests.

+3
source

You have several options:

  • enter your queries into the database
  • logger , . . , , config, sql . , API , , ()
+1

, 1, , IO, . (, n) , . , , , .

0

For the record (you did not specify your database) Postgresql has a set of parameters related to logging. Among them, I use log_min_duration_statement to log requests that have been running for more than N seconds. Useful for profiling without filling out your log files and without interfering with performance. I would say that most databases have something similar.

0
source

Source: https://habr.com/ru/post/1748569/


All Articles