[i/208] Reducing SN load PRs are causing errors

Old commit messages:

[i/208] fixing errors caused by reducing load PRs

[i/208] moving sql string to be generated only if needed
Merge pull request #208 from Senky/i/208

Reducing SN load PRs are causing errors