My code in the Editor is slow, what can I do?


Sometimes when you are editing a channel the auto-execution can start to get very slow. This usually happens because channels have a lot of code and it gets slow to compile, or there is a long channel timeout to allow for unreliable database or web service connections. Also large database queries that take a long time will slow down the annotations.

You can use iguana.isTest() to detect when you are running a development environment (test mode) and change code behaviour to improve performance. You can also use  iguana.setTimeout() to reduce the channel timeout.

Issue [top]

What to do when your code is slow in the Editor.

Solution [top]

You can do a couple of things:

  1. If you have a large project that takes a long time to compile you can disable auto-execution and run the code manually when you want to update annotations.
  2. Also you can modify the code to run quicker in the editor using iguana.isTest() and iguana.setTimeout().
  3. If you have slow database queries you can do various things to speed them up:
    • You can use a development database with limited data — so you get smaller result sets
    • You can change the queries to return less row for example SELECT TOP 10 <query> will be much faster:

      If you use this approach you need to be careful not to put the modified queries into production — the best way to prevent this is to use the iguana.isTest() function so you only run the modified queries in test mode (in the editor).

    • You can optimize the queries for better performance — your production users will appreciate this too:

      Queries can usually be optimized to run much faster (often 100s or 10000s of times), speak to your DBA (database administrator).

How it Works [top]

The more code you have in your channel the longer it will take to compile, eventually this slows down the Editor enough to become annoying. Disabling auto-execution can be useful in this scenario. You may also find using iguana.isTest() helpful as you can bypass portions of the code (that are slow to compile) and simply return dummy/test data instead.

If you are using external services like databases or web services which can be unreliable, then you will need a longer channel timeout to allow for delayed responses. Such timeouts are appropriate for a Production system, but can waste a lot of time during development. You can use iguana.setTimeout() to reduce the timeout for a development environment to maybe 15 seconds — as opposed to the default of 15 minutes. Alternatively you could use iguana.isTest() to simply return some dummy/test data instead of querying a database or web service (thus avoiding timeouts altogether).

Large (and slow) Database queries will slow down the editor as they need to be refreshed (run) each time the code is changed — because the annotations need to be refreshed.

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.