<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>On Mar 19, 2010, at 12:24 PM, Russell Valentine wrote:</div><div><br></div><div><blockquote type="cite"><div>Perhaps time each part to see what exactly is taking up the time? </div></blockquote><br><br></div><div>Thanks for the suggestion. I was hoping to find a global parameter (buffer_size, or similar) that could be tweaked to improve overall performance.</div><div><br></div><div>My app loads a dozen QSqlRelationalTableModel objects, in addition to various support data. Remotely, each table model requires roughly 2 to 3 seconds to load. Locally, each requires 0.12 seconds to load! </div><div><br></div><div>I'm already printing timing statements to help with my optimization efforts to date. Complete output is long. Here are some highlights:</div><div><br></div><div>#-------------------------------------------------------------------------------</div><div># remote data launch</div><div>#-------------------------------------------------------------------------------</div><div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--StartFragment--><span style=" color:#ff0000;">2010-03-19 12:56:02.580540</span> Application launch<!--EndFragment--></div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><br></div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--StartFragment--><span style=" color:#ff0000;">2010-03-19 12:56:05.538501</span> connecting...</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><span style=" color:#ff0000;">2010-03-19 12:56:06.564915</span> database connection opened</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--EndFragment--></div></div></div><div>[ ~1 second to open the connection ]</div><div><br></div><div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--StartFragment--><span style=" color:#ff0000;">2010-03-19 12:56:11.091056</span> loading application support data...</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><span style=" color:#ff0000;">2010-03-19 12:56:16.912604</span> user data loaded...</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--EndFragment--></div></div><div>[ ~6 seconds to load QSqlRelationalTableModel objects, using unfiltered select() methods ]</div><div><br></div><div>...</div><div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--StartFragment--><span style=" color:#ff0000;">2010-03-19 12:56:24.943313</span> form 3/12 set</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><span style=" color:#ff0000;">2010-03-19 12:56:27.320105</span> form 4/12 set</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">...</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">[ ~2.5 seconds for each of 12 forms to load additional data model objects and set widgets accordingly ]</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--EndFragment--></div></div><div><br></div><div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--StartFragment--><span style=" color:#ff0000;">2010-03-19 12:56:45.861150</span> ready...</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">[ ~43 seconds to launch ]</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--EndFragment--></div></div><div><br></div><div><br></div><div><br></div><div><div>#-------------------------------------------------------------------------------</div><div># local data launch</div><div>#-------------------------------------------------------------------------------</div></div><div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--StartFragment--><span style=" color:#ff0000;">2010-03-19 13:13:02.606677 <span class="Apple-style-span" style="color: rgb(0, 0, 0); ">Application launch</span></span></div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">...</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--StartFragment--><span style=" color:#ff0000;">2010-03-19 13:13:05.733303</span> form 3/12 set</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><span style=" color:#ff0000;">2010-03-19 13:13:05.854210</span> form 4/12 set</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">[ ~0.12 seconds for each of 12 forms to load additional data model objects and set widgets accordingly ]</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--EndFragment--></div></div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><font class="Apple-style-span" color="#FF0000">...</font></div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; "><!--StartFragment--><span style=" color:#ff0000;">2010-03-19 13:13:06.710319</span> ready...</div><div style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; text-indent: 0px; ">[ ~4 seconds to launch, start to finish ]</div></div></div><div><br></div><div><br></div><div><br></div><div><blockquote type="cite"><div>One<br>way to do so is below:<br><br>t=time.time()<br>dostuff()<br>print "dostuff() time = "+str(time.time()-t)+" s"<br><br>Is it really the initial connection that takes a long time to get, or is<br>it something else on that remote machine. work_mem has nothing to do<br>with making a connection for example.<br><br>On 03/19/10 14:06, Scott Frankel wrote:<br><blockquote type="cite"><br></blockquote><blockquote type="cite">Hi all,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Would anyone have any suggestions for improving QSqlDatabase PSQL<br></blockquote><blockquote type="cite">connection performance?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The Qt docs refer to PSQL connection options and demonstrate the<br></blockquote><blockquote type="cite">"requiressl=1" example. Are there other options that can be set? (eg: <br></blockquote><blockquote type="cite">the docs' PostgreSQL "options" bullet point) Google searches are coming<br></blockquote><blockquote type="cite">up short.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I note that my local postgresql.conf file has a "work_mem" statement. <br></blockquote><blockquote type="cite">(Usage: work_mem = 1MB) That could be germane, but including the term<br></blockquote><blockquote type="cite">in my setConnectOptions() method (as part of a semi-colon separated<br></blockquote><blockquote type="cite">list) yields PSQL errors.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I've optimized my working code further. Running from a local data set,<br></blockquote><blockquote type="cite">launch times are down to 4 seconds. Running from an identical data set<br></blockquote><blockquote type="cite">hosted remotely, my application launches in 40+ seconds!<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks in advance!<br></blockquote><blockquote type="cite">Scott<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On Mar 16, 2010, at 9:09 PM, Scott Frankel wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Hi all,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Is there a buffer size or similar optimization parameter that can be<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">set for QSqlDatabase PSQL connections? The docs refer to PostgreSQL<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">"options" without specifying what they may be.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">I have a PG database cluster of about 7MB, spread over a couple dozen<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">tables. Locally, it takes about 6 seconds to launch my app, loading<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">the model data into my forms.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">When I pull an identical data-set from a remote location, my<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">application launch time increases to over 60 seconds. Yet resource<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">utilization on the remote server is miniscule.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">For comparison, I'm able to download the results of a 21MB SELECT<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">statement in less than 8 seconds via cmd-line psql. That's orders of<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">magnitude more data in an order of magnitude less time!<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">I'm creating my db connection as follows. (Sample code attached also.)<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> db = QtSql.QSqlDatabase.addDatabase("QPSQL")<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> db.setDatabaseName("fubar")<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> db.setHostName("localhost")<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> db.setUserName("admin")<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> db.setPassword("abc123")<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Thanks in advance!<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Scott<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><dbTest.002.py><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">_______________________________________________<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br></blockquote><blockquote type="cite"><a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote><br><br></div></blockquote></div><br><div apple-content-edited="true"> <div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="font-size: 12px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>Scott Frankel</div><div>President</div><div>Circle-S Studios</div><div><br></div><div>510-339-7477 (o)</div><div>510-332-2990 (c)</div><div><br></div><div><a href="http://www.circlesfx.com">www.circlesfx.com</a></div><div><a href="http://www.sequoyaworkflow.com">www.sequoyaworkflow.com</a></div><div><br class="khtml-block-placeholder"></div><div><br class="khtml-block-placeholder"></div><br class="Apple-interchange-newline"></span></span></span></span></div></span></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"> </div><br></body></html>