Ticket #4732 (closed defect: fixed)
Opened 5 years ago
Last modified 5 years ago
pypgsql overuses server-side cursors resulting in large performance penalty
| Reported by: | Jeremy Kemper <jeremy@…> | Owned by: | cboos |
|---|---|---|---|
| Priority: | high | Milestone: | 0.10.4 |
| Component: | general | Version: | 0.10.3 |
| Severity: | major | Keywords: | pypgsql cursor |
| Cc: | jeremy@… | ||
| Release Notes: | |||
| API Changes: | |||
Description
Most trac + postgres installs are using pyscopg2 which pulls full result sets for cursor.execute by default.
pypgsql, on the other hand, uses server-side cursors by default, leading to incredibly inefficient queries: rather than fetch e.g. select ... limit 20 all at once, it does declare cursor; fetch 1; fetch 1; ...
Fortunately, server-side cursors can be turned off with great results. I imagine some of pypgsql's widespread perception of slowness with Trac is due to this strange default behavior.
Attachments
Change History
Changed 5 years ago by Jeremy Kemper <jeremy@…>
- Attachment pypgsql_cursor_fix.diff added
comment:1 Changed 5 years ago by cboos
- Owner changed from jonas to cboos
- Priority changed from normal to high
Thanks for the investigation and the fix!
comment:2 Changed 5 years ago by cboos
- Resolution set to fixed
- Status changed from new to closed



disable server-side cursors when using pypgsql