[PyQt] QSqlDatabase connection parameters
Russell Valentine
russ at coldstonelabs.org
Fri Mar 19 19:24:40 GMT 2010
Perhaps time each part to see what exactly is taking up the time? One
way to do so is below:
t=time.time()
dostuff()
print "dostuff() time = "+str(time.time()-t)+" s"
Is it really the initial connection that takes a long time to get, or is
it something else on that remote machine. work_mem has nothing to do
with making a connection for example.
On 03/19/10 14:06, Scott Frankel wrote:
>
> Hi all,
>
> Would anyone have any suggestions for improving QSqlDatabase PSQL
> connection performance?
>
>
> The Qt docs refer to PSQL connection options and demonstrate the
> "requiressl=1" example. Are there other options that can be set? (eg:
> the docs' PostgreSQL "options" bullet point) Google searches are coming
> up short.
>
> I note that my local postgresql.conf file has a "work_mem" statement.
> (Usage: work_mem = 1MB) That could be germane, but including the term
> in my setConnectOptions() method (as part of a semi-colon separated
> list) yields PSQL errors.
>
> I've optimized my working code further. Running from a local data set,
> launch times are down to 4 seconds. Running from an identical data set
> hosted remotely, my application launches in 40+ seconds!
>
> Thanks in advance!
> Scott
>
>
>
> On Mar 16, 2010, at 9:09 PM, Scott Frankel wrote:
>
>>
>> Hi all,
>>
>> Is there a buffer size or similar optimization parameter that can be
>> set for QSqlDatabase PSQL connections? The docs refer to PostgreSQL
>> "options" without specifying what they may be.
>>
>> I have a PG database cluster of about 7MB, spread over a couple dozen
>> tables. Locally, it takes about 6 seconds to launch my app, loading
>> the model data into my forms.
>>
>> When I pull an identical data-set from a remote location, my
>> application launch time increases to over 60 seconds. Yet resource
>> utilization on the remote server is miniscule.
>>
>> For comparison, I'm able to download the results of a 21MB SELECT
>> statement in less than 8 seconds via cmd-line psql. That's orders of
>> magnitude more data in an order of magnitude less time!
>>
>> I'm creating my db connection as follows. (Sample code attached also.)
>>
>> db = QtSql.QSqlDatabase.addDatabase("QPSQL")
>> db.setDatabaseName("fubar")
>> db.setHostName("localhost")
>> db.setUserName("admin")
>> db.setPassword("abc123")
>>
>>
>> Thanks in advance!
>> Scott
>>
>>
>> <dbTest.002.py>
>>
>>
>> _______________________________________________
>> PyQt mailing list PyQt at riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>
>
>
>
>
>
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
More information about the PyQt
mailing list