Small delays in SQL queries

Viewed 54

I am trying to troubleshoot why some of our backoffice pages (and some frontend with categories containing many products) takes a bit too long to load. Each sql in the queries that are used aren't that intense, but there seems to be microdelays every so often which causes problems.

An example I am working on now is checking if all products of a store have language translations (and a few other things). While each product takes a rather short time, we have over a thousand products, and together it stacks up since there are a few queries that happens for each product.

Here is a small testcode I created in ASP classic (which is the language we are using). It's basically a loop that loads a query and puts the product description into a variable for the same product over and over 1000 times and writes out the current time for each loop.

sql = _
"SELECT language_prod_desc " &_
"  FROM language_prod " &_
" WHERE language_prod_pid = 30761462 " &_
"   AND language_prod_lang = 'no' "

for i = 0 to 1000
    set rs = cn.execute(SQL)
    desc = rs("language_prod_desc").value
    response.write (10000+i) & "<strong>  " & mid(timer(),3,6) & "</strong><br>"
next

Here is a small sample of the output to show that there are sometimes small 0.02s delays in the loops.

10000 296,39
10001 296,39
10002 296,39
10003 296,39
10004 296,39
10005 296,41 <---
10006 296,41
10007 296,41
10008 296,41
10009 296,41
10010 296,41
10011 296,41
10012 296,41
10013 296,41
10014 296,41
10015 296,41
10016 296,41
10017 296,43 <---
10018 296,43
10019 296,43
10020 296,43
10021 296,43
10022 296,43

I am using IIS10, running MySQL 5.0.12.

Question: What could be causing these "microdelays" or how could I go about troubleshooting what is causing them?

0 Answers
Related