Threading in SQL Anywhere

To understand the SQL Anywhere threading model, you must also understand the basic terminology and concepts of threading and request processing:

  • Request   A request is a unit of work, such as a query or SQL statement, sent to the database server over a connection. The lifetime of a request spans the time from when the request is first received by the database server to the time that the last of the results are returned, cursors are closed, or the request is canceled.

  • Task   A task is a unit of activity that is performed within the database server, and is the smallest unit of work that is scheduled by the server. Within the database server, each user request becomes at least one task, and possibly more if intra-query parallelism is involved. In addition to user requests, the database server can also schedule its own tasks to perform internal housekeeping chores, such as running the cleaner or processing timers. The maximum number of active tasks that can execute concurrently is set by the -gn option. If more tasks arrive at the database server than can be concurrently processed, they are queued for execution. If an active task, or a task for which processing has already begun, needs to block for some reason during its processing, such as while waiting for a lock, or for I/O to complete, it is still considered to be active. It therefore counts against the upper bound place by the value of the -gn option.

  • Thread   A thread is an operating system construct that represents an executing thread-of-control within an application. Every operating system process, including the database server, is executed by at least one, and possibly many threads. A thread is scheduled outside of the application by the operating system, and ultimately, all of an application's execution is performed by its threads. Tasks, within a SQL Anywhere database server, execute on an operating system thread. At startup, SQL Anywhere creates a fixed number of threads, controlled by the -gtc option (on Windows and Linux), or the -gn option (on Unix).

See also

Tasks on Unix
Tasks on Windows and Linux
Controlling threading behavior
Setting the database server's multiprogramming level