{"id":369,"date":"2006-09-12T14:46:05","date_gmt":"2006-09-12T19:46:05","guid":{"rendered":"http:\/\/ywwg.com\/wordpress\/?p=369"},"modified":"2007-01-07T17:52:14","modified_gmt":"2007-01-07T22:52:14","slug":"penguintv-optimization","status":"publish","type":"post","link":"https:\/\/ywwg.com\/wordpress\/archives\/369","title":{"rendered":"PenguinTV optimization"},"content":{"rendered":"<p>I&#8217;ve been going through the crufty and scary ptvDB.py looking for ways to improve performance.  Armed with the trust profile and pstats modules, I cut polling time in half by removing redundant and unnecessary database hits.<\/p>\n<p>I then got the idea of generating a print statement every time I hit the DB, so I can see exactly what the database is doing during regular operation.<\/p>\n<p>The result is not always pretty:<\/p>\n<p>Basic article read:<br \/>\n<code><br \/>\nSELECT title, creator, link, description, feed_id, date FROM entries WHERE id=? (69443,)  ok<br \/>\nSELECT id,entry_id,url,file,download_status,viewed,length,mimetype FROM media WHERE entry_id = ? (69443,)  ok<br \/>\nSELECT read FROM entries WHERE id=? (69443,)  ok<\/code><\/p>\n<p>Ok that&#8217;s fine, we get the entry, any associated media, and then the read state.<\/p>\n<p>What about an unread entry?<br \/>\n<code>SELECT title, creator, link, description, feed_id, date FROM entries WHERE id=? (67523,)  ok<br \/>\nSELECT id,entry_id,url,file,download_status,viewed,length,mimetype FROM media WHERE entry_id = ? (67523,)  ok<br \/>\nSELECT read FROM entries WHERE id=? (67523,)  ok<br \/>\nUPDATE entries SET read=? WHERE id=? (1, 67523)  ok<br \/>\nUPDATE media SET viewed=? WHERE entry_id=? (1, 67523)  ok<br \/>\nSELECT read FROM entries WHERE id=? (67523,)  ok<br \/>\nSELECT id,entry_id,url,file,download_status,viewed,length,mimetype FROM media WHERE entry_id = ? (67523,)  ok<br \/>\nSELECT title, creator, link, description, feed_id, date FROM entries WHERE id=? (67523,)  ok<br \/>\nSELECT id,entry_id,url,file,download_status,viewed,length,mimetype FROM media WHERE entry_id = ? (67523,)  ok<br \/>\nSELECT read FROM entries WHERE id=? (67523,)  ok<br \/>\nSELECT feed_pointer,description FROM feeds WHERE id=? (233,)  ok<br \/>\nSELECT id,title,fakedate FROM entries WHERE feed_id=? ORDER BY fakedate DESC (233,)  ok<br \/>\nSELECT id FROM entries WHERE feed_id=? (233,)  ok<br \/>\nSELECT feed_pointer FROM feeds WHERE id=? (233,)  ok<br \/>\nSELECT pollfail FROM feeds WHERE id=? (233,)  ok<br \/>\nSELECT feed_pointer FROM feeds WHERE id=? (233,)  ok<br \/>\nSELECT read FROM entries WHERE feed_id=? (233,)  ok<br \/>\nSELECT id FROM feeds WHERE feed_pointer=? (233,)  ok<br \/>\n<\/code><\/p>\n<p>Oops.  It&#8217;s whacking the database three times for the entry data, and updates the whole feed as well.  Time to figure out what I&#8217;m doing wrong!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been going through the crufty and scary ptvDB.py looking for ways to improve performance. Armed with the trust profile and pstats modules, I cut polling time in half by removing redundant and unnecessary database hits. I then got the idea of generating a print statement every time I hit the DB, so I can &hellip; <a href=\"https:\/\/ywwg.com\/wordpress\/archives\/369\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;PenguinTV optimization&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,23,26,25],"tags":[],"_links":{"self":[{"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/posts\/369"}],"collection":[{"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/comments?post=369"}],"version-history":[{"count":0,"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/posts\/369\/revisions"}],"wp:attachment":[{"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/media?parent=369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/categories?post=369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ywwg.com\/wordpress\/wp-json\/wp\/v2\/tags?post=369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}