Re: performance issue with psycopg
От | Sushant Sinha |
---|---|
Тема | Re: performance issue with psycopg |
Дата | |
Msg-id | 1323711974.2132.9.camel@dragflick обсуждение исходный текст |
Ответ на | Re: performance issue with psycopg (Daniele Varrazzo <daniele.varrazzo@gmail.com>) |
Ответы |
Re: performance issue with psycopg
|
Список | psycopg |
On Mon, 2011-12-12 at 17:20 +0000, Daniele Varrazzo wrote: > On Mon, Dec 12, 2011 at 4:41 PM, Sushant Sinha <sushant354@gmail.com> wrote: > > I am using psycopg 2.4.2 and facing performance issue. An explain > > analyze of the query on the database shows 0.75secs. But when used > > through the psycopg layer I am seeing 1.5 secs. Any idea why the extra > > cost and how to optimize it? > > > > from psycopg2.extras import DictCursor > > from psycopg2.extensions import UNICODE, UNICODEARRAY > > psycopg2.extensions.register_type(UNICODE) > > psycopg2.extensions.register_type(UNICODEARRAY) > > > > > > cursor = dbCnx.cursor(cursor_factory=DictCursor) > > cursor.execute(query, params) > > results = cursor.fetchall() > > What is the performance using only the basic cursor? And how big is > the returned set? > > -- Daniele Number of rows: 25111, number of columns: 12 With basic cursor it is 1.2 secs 1 0.000 0.000 1.230 1.230 a.py:1(<module>) 1 0.876 0.876 0.877 0.877 {method 'execute' of 'psycopg2._psycopg.cursor' objects} 1 0.142 0.142 0.202 0.202 {method 'fetchall' of 'psycopg2._psycopg.cursor' objects} 1 0.000 0.000 0.148 0.148 db_utility.py:1(<module>) 1 0.002 0.002 0.132 0.132 extras.py:5(<module>) 1 0.000 0.000 0.125 0.125 uuid.py:45(<module>) 2 0.000 0.000 0.120 0.060 util.py:235(find_library) 2 0.000 0.000 0.120 0.060 util.py:207(_findSoname_ldconfig)
В списке psycopg по дате отправления: