2

Specifically regarding MySQL, what is the difference between a thread and a process? The documentation seems to refer to them interchangeably at times, and it even throws in the term "session" too.

At the most basic level, the command to show threads includes the term PROCESSLIST, as if a list of processes is a list of threads. (https://dev.mysql.com/doc/refman/5.6/en/show-processlist.html -- The first sentence says this list "shows which threads are running.") But then, in the performance_schema.threads table, each thread there has its own unique thread_id that is not the ID returned from SHOW [FULL] PROCESSLIST. Instead, PROCESSLIST_ID is a foreign key to the PROCESSLIST (https://dev.mysql.com/doc/refman/5.6/en/threads-table.html). This leads me to believe that threads and processes are not the same thing.

  • I've added an example with a couple links. As a preface, please forgive any blind ignorance. I'm new to this side of the database (my experience has mostly been development when working with databases). – Jacob Armstrong Jun 21 '19 at 20:13
0

MySQL has been implemented on a lot of Operating Systems -- From Atari to Windows to Solaris to Linux. Different OSs work differently when it comes to "processes" versus "threads". MySQL picked whichever was better in each case. Then it got sloppy in saying "THREADS_runnng" and "show PROCESSlist".

So, in MySQL context, "threads" and "processes" are synonymous.

In Operating System context, they are different enough to necessitate multiple courses in Computer Science.

In MySQL, one connection uses one thread (or process). There is also a main thread (process) for coordinating between the connections. Also, InnoDB has some extra threads (which may actually be threads and not processes?) to deal with background I/O tasks.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.