How to rebuild mesh in optimized way? Example inside I've made an example house out of blocks. Is there any way to automatically rebuild my model into one solid mesh without unnececarry polygons?
There isn't one.  Because you created individual blocks, even when they're joined they're still independent meshes. Tools like dissolve faces only work on completely connected meshes.