Re: performance issue with psycopg

From: Sushant Sinha <sushant354(at)gmail(dot)com>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: psycopg(at)postgresql(dot)org
Subject: Re: performance issue with psycopg
Date: 2011-12-12 17:46:14
Message-ID: 1323711974.2132.9.camel@dragflick
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmail(dot)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)

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2011-12-12 19:08:24 Re: performance issue with psycopg
Previous Message Daniele Varrazzo 2011-12-12 17:20:01 Re: performance issue with psycopg