TheBB/aligulac — pull request #106 by Prillan (2013-11-29 13:20:51+00:00)
Title: Improved some db queries.

Speedups (on live server):

* add
- 3.5~4 times
* eventmgr
- 35~45 times

To test:
1. Get the files
- https://gist.github.com/Prillan/01124ebeca39de0ad61b
- https://gist.github.com/Prillan/8d33615dc40302384af7
- https://gist.github.com/Prillan/34e47a00d40b6eb6fad9
- https://gist.github.com/Prillan/5f3476dbf8be2082fcfd
- https://gist.github.com/Prillan/55c00eaad43da07a89e7
2. Put them in `/tmp`
3. Run `./test.sh`

You should see output like this:
````
--- Testing add.noopt.sql (#1)---

real 0m4.357s
user 0m0.030s
sys 0m0.017s
------------------
--- Testing add.opt.sql (#1)---

real 0m1.839s
user 0m0.027s
sys 0m0.017s
------------------
Same results
--- Testing add.noopt.sql (#2)---

real 0m4.333s
user 0m0.030s
sys 0m0.014s
------------------
--- Testing add.opt.sql (#2)---

real 0m1.221s
user 0m0.026s
sys 0m0.018s
------------------
Same results
--- Testing eventmgr.noopt.sql (#1)---

real 0m5.457s
user 0m0.052s
sys 0m0.008s
------------------
--- Testing eventmgr.opt.sql (#1)---

real 0m0.159s
user 0m0.046s
sys 0m0.014s
------------------
Same results
--- Testing eventmgr.noopt.sql (#2)---

real 0m6.072s
user 0m0.051s
sys 0m0.010s
------------------
--- Testing eventmgr.opt.sql (#2)---

real 0m0.136s
user 0m0.049s
sys 0m0.013s
------------------
Same results

````