diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-02-25 23:00:52 +0000 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-02-26 00:46:23 +0000 |
| commit | 4412826556ea5af86ca2be0cf03a691f4e7cdadb (patch) | |
| tree | 5f46aa44ecb76e980287947ea56488bd1b243113 /doc/src/faq.rst | |
| parent | 3636bc4201eaa13939da1e6928e61ec16f8271a8 (diff) | |
| download | psycopg2-4412826556ea5af86ca2be0cf03a691f4e7cdadb.tar.gz | |
Added documentation for the 'pool' module.
Diffstat (limited to 'doc/src/faq.rst')
| -rw-r--r-- | doc/src/faq.rst | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/doc/src/faq.rst b/doc/src/faq.rst index 00501d7..9041ead 100644 --- a/doc/src/faq.rst +++ b/doc/src/faq.rst @@ -85,14 +85,15 @@ When should I save and re-use a cursor as opposed to creating a new one as neede suggestion is to almost always create a new cursor and dispose old ones as soon as the data is not required anymore (call :meth:`~cursor.close` on them.) The only exception are tight loops where one usually use the same - cursor for a whole bunch of INSERTs or UPDATEs. + cursor for a whole bunch of :sql:`INSERT`\s or :sql:`UPDATE`\s. When should I save and re-use a connection as opposed to creating a new one as needed? Creating a connection can be slow (think of SSL over TCP) so the best practice is to create a single connection and keep it open as long as required. It is also good practice to rollback or commit frequently (even - after a single SELECT statement) to make sure the backend is never left - "idle in transaction". + after a single :sql:`SELECT` statement) to make sure the backend is never + left "idle in transaction". See also :mod:`psycopg2.pool` for lightweight + connection pooling. What are the advantages or disadvantages of using named cursors? The only disadvantages is that they use up resources on the server and |
