{"id":249,"date":"2011-12-09T23:26:51","date_gmt":"2011-12-10T04:26:51","guid":{"rendered":"http:\/\/littlesvr.ca\/grumble\/?p=249"},"modified":"2012-12-05T00:53:03","modified_gmt":"2012-12-05T05:53:03","slug":"number-of-sql-queries-per-page","status":"publish","type":"post","link":"http:\/\/littlesvr.ca\/grumble\/2011\/12\/09\/number-of-sql-queries-per-page\/","title":{"rendered":"Number of SQL queries per page"},"content":{"rendered":"<p>If someone updates a po file with 100 translations &#8211; I need to figure out whether each translation is already in the database, and if not &#8211; insert it. The result looks like this (more about &#8220;looks&#8221; later):<\/p>\n<p><a href=\"http:\/\/littlesvr.ca\/grumble\/wp-content\/uploads\/2011\/12\/pouploadinsertedstrings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-250\" title=\"pouploadinsertedstrings\" src=\"http:\/\/littlesvr.ca\/grumble\/wp-content\/uploads\/2011\/12\/pouploadinsertedstrings.png\" alt=\"\" width=\"522\" height=\"189\" srcset=\"http:\/\/littlesvr.ca\/grumble\/wp-content\/uploads\/2011\/12\/pouploadinsertedstrings.png 522w, http:\/\/littlesvr.ca\/grumble\/wp-content\/uploads\/2011\/12\/pouploadinsertedstrings-300x108.png 300w\" sizes=\"auto, (max-width: 522px) 100vw, 522px\" \/><\/a><\/p>\n<p>This is just a snippet.<\/p>\n<p>I am concerned that running an SQL query like this:<\/p>\n<blockquote>\n<pre>\"SELECT Translation.TranslatedString FROM Translation,Language WHERE \" .\r\n\"Translation.LanguageID = Language.LanguageID AND Language.LanguageCode = '%s' \" .\r\n\"AND Translation.EnglishString = '%s'\"<\/pre>\n<\/blockquote>\n<p>for every line uploaded might be a bit too much. Is it?<\/p>\n<p>The prevailing wisdom on the internet seems to be that more than a few queries per page is too much. But I wonder if that&#8217;s for viewing content rather than uploading. Perhaps for uploading content this is not too bad. I mean I hope a lot of uploading is going to happen but that&#8217;s not the most common use case.<\/p>\n<p>Regardless, I can&#8217;t think of an easy way to optimise this. I would have to spend a lot more time on the database design. Maybe when (if?) the site gets popular I will have the motivation to learn more fancy DB optimisations.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If someone updates a po file with 100 translations &#8211; I need to figure out whether each translation is already in the database, and if not &#8211; insert it. The result looks like this (more about &#8220;looks&#8221; later): This is just a snippet. I am concerned that running an SQL query like this: &#8220;SELECT Translation.TranslatedString &hellip; <\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-andrew","4":"post-249","6":"format-standard","7":"category-ostd","8":"category-safeforseneca"},"_links":{"self":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/comments?post=249"}],"version-history":[{"count":5,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/249\/revisions"}],"predecessor-version":[{"id":609,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/posts\/249\/revisions\/609"}],"wp:attachment":[{"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/media?parent=249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/categories?post=249"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/littlesvr.ca\/grumble\/wp-json\/wp\/v2\/tags?post=249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}